I'm using Appium (v1.15.1) to find email a password fields from "http://facebook.com" with Chrome browser on Android device, and i'm unable to find email and password fields elements using method findElementById('') and findElementByName(''). I've tried to find it using XPath and it works.
This is my code:
public class Browse extends BaseMobile {
public static void main(String[] args) throws MalformedURLException {
AndroidDriver<AndroidElement> driver = capabilities();
driver.get("http://facebook.com");
driver.findElementById("m_login_email").sendKeys("prueba@mail.com"); // not working
driver.findElementByName("pass").sendKeys("123456789"); // not working
driver.findElementByXPath("//*[@name='login']").click();
}
}
capabilities:
public class BaseMobile {
public static AndroidDriver<AndroidElement> capabilities() throws MalformedURLException {
AndroidDriver<AndroidElement> androidDriver;
String serverUrl = "http://127.0.0.1:4723/wd/hub";
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android device");
cap.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");
androidDriver = new AndroidDriver<AndroidElement>(new URL(serverUrl), cap);
androidDriver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
return androidDriver;
}
}
Error:
Exception in thread "main" org.openqa.selenium.InvalidArgumentException: invalid argument: invalid locator (Session info: chrome=79.0.3945.136)
EDIT(1): As suggested I printed page source and I'm getting it without any problem. Added appium log too.