Hi, I am trying to automate a simple login page on chrome or android browser on real device/emulator. But .click() is not working. Tried using all below options but none worked
- tried using WebElement/MobileElement click() method.
- tried using javascript click.
- tried using TouchAction tap
- tried using javascript mobile:tap
Sample code is below and also attached the appium logs. This has blocked me terribly, can someone please let know what am i missing here. Note that same code works fine on desktop
code
public class TestMobileBrowser {
public DesiredCapabilities capabilities;
public RemoteWebDriver driver;
@BeforeTest
public void beforeTest() throws MalformedURLException{
capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "Android");
capabilities.setCapability("browserName", "Browser");
capabilities.setCapability("newCommandTimeout", 60);
driver = new AndroidDriver<WebElement>(new URL("http://localhost:4723/wd/hub"), capabilities);
}
@Test
public void test() throws InterruptedException{
WebDriverWait wait = new WebDriverWait(driver, 30);
driver.get("http://testurl");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//input[@name='userName']")));
driver.findElement(By.xpath("//input[@name='userName']")).sendKeys("testvk1");
driver.findElement(By.xpath("//input[@name='password']")).sendKeys("test123");
driver.findElement(By.xpath("//input[@name='password']")).sendKeys(Keys.TAB);
elementHighlight(driver.findElement(By.id("button-1041"))); //this method highlights the element correctly using javascript
wait.until(ExpectedConditions.elementToBeClickable(By.id("button-1041")));
driver.findElement(By.id("button-1041")).click();
}
Appium Logs
info: --> POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element {"using":"xpath","value":"//input[@name='password']"}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element] to [POST http://127.0.0.1:9515/wd/hub/session/23865a2b1a7d285514a579c17653139b/element] with body: {"using":"xpath","value":"//input[@name='password']"}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"23865a2b1a7d285514a579c17653139b","status":0,"value":{"ELEMENT":"0.30240034498274326-2"}}
info: JSONWP Proxy: Replacing sessionId 23865a2b1a7d285514a579c17653139b with 23865a2b1a7d285514a579c17653139b
info: <-- POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element 200 804.649 ms - 103
info: --> POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element/0.30240034498274326-2/value {"id":"0.30240034498274326-2","value":["test123"]}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element/0.30240034498274326-2/value] to [POST http://127.0.0.1:9515/wd/hub/session/23865a2b1a7d285514a579c17653139b/element/0.30240034498274326-2/value] with body: {"id":"0.30240034498274326-2","value":["egain123"]}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"23865a2b1a7d285514a579c17653139b","status":0,"value":null}
info: JSONWP Proxy: Replacing sessionId 23865a2b1a7d285514a579c17653139b with 23865a2b1a7d285514a579c17653139b
info: <-- POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element/0.30240034498274326-2/value 200 5613.754 ms - 72
info: --> POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element {"using":"xpath","value":"//input[@name='password']"}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element] to [POST http://127.0.0.1:9515/wd/hub/session/23865a2b1a7d285514a579c17653139b/element] with body: {"using":"xpath","value":"//input[@name='password']"}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"23865a2b1a7d285514a579c17653139b","status":0,"value":{"ELEMENT":"0.30240034498274326-2"}}
info: JSONWP Proxy: Replacing sessionId 23865a2b1a7d285514a579c17653139b with 23865a2b1a7d285514a579c17653139b
info: <-- POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element 200 140.445 ms - 103
info: --> POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element/0.30240034498274326-2/value {"id":"0.30240034498274326-2","value":[""]}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element/0.30240034498274326-2/value] to [POST http://127.0.0.1:9515/wd/hub/session/23865a2b1a7d285514a579c17653139b/element/0.30240034498274326-2/value] with body: {"id":"0.30240034498274326-2","value":[""]}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"23865a2b1a7d285514a579c17653139b","status":0,"value":null}
info: JSONWP Proxy: Replacing sessionId 23865a2b1a7d285514a579c17653139b with 23865a2b1a7d285514a579c17653139b
info: <-- POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element/0.30240034498274326-2/value 200 1060.420 ms - 72
info: --> POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element {"using":"id","value":"button-1041"}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element] to [POST http://127.0.0.1:9515/wd/hub/session/23865a2b1a7d285514a579c17653139b/element] with body: {"using":"id","value":"button-1041"}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"23865a2b1a7d285514a579c17653139b","status":0,"value":{"ELEMENT":"0.30240034498274326-3"}}
info: JSONWP Proxy: Replacing sessionId 23865a2b1a7d285514a579c17653139b with 23865a2b1a7d285514a579c17653139b
info: <-- POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element 200 285.739 ms - 103
info: --> POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/execute {"script":"arguments[0].style.border='3px solid yellow'","args":[{"ELEMENT":"0.30240034498274326-3","element-6066-11e4-a52e-4f735466cecf":"0.30240034498274326-3"}]}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/execute] to [POST http://127.0.0.1:9515/wd/hub/session/23865a2b1a7d285514a579c17653139b/execute] with body: {"script":"arguments[0].style.border='3px solid yellow'","args":[{"ELEMENT":"0.30240034498274326-3","element-6066-11e4-a52e-4f735466cecf":"0.30240034498274326-3"}]}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"23865a2b1a7d285514a579c17653139b","status":0,"value":null}
info: JSONWP Proxy: Replacing sessionId 23865a2b1a7d285514a579c17653139b with 23865a2b1a7d285514a579c17653139b
info: <-- POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/execute 200 64.399 ms - 72
info: --> POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/execute {"script":"arguments[0].style.border=''","args":[{"ELEMENT":"0.30240034498274326-3","element-6066-11e4-a52e-4f735466cecf":"0.30240034498274326-3"}]}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/execute] to [POST http://127.0.0.1:9515/wd/hub/session/23865a2b1a7d285514a579c17653139b/execute] with body: {"script":"arguments[0].style.border=''","args":[{"ELEMENT":"0.30240034498274326-3","element-6066-11e4-a52e-4f735466cecf":"0.30240034498274326-3"}]}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"23865a2b1a7d285514a579c17653139b","status":0,"value":null}
info: JSONWP Proxy: Replacing sessionId 23865a2b1a7d285514a579c17653139b with 23865a2b1a7d285514a579c17653139b
info: <-- POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/execute 200 66.011 ms - 72
info: --> POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element {"using":"xpath","value":"//span[text()='Sign In']"}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element] to [POST http://127.0.0.1:9515/wd/hub/session/23865a2b1a7d285514a579c17653139b/element] with body: {"using":"xpath","value":"//span[text()='Sign In']"}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"23865a2b1a7d285514a579c17653139b","status":0,"value":{"ELEMENT":"0.30240034498274326-4"}}
info: JSONWP Proxy: Replacing sessionId 23865a2b1a7d285514a579c17653139b with 23865a2b1a7d285514a579c17653139b
info: <-- POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element 200 187.943 ms - 103
info: --> POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element/0.30240034498274326-4/click {"id":"0.30240034498274326-4"}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element/0.30240034498274326-4/click] to [POST http://127.0.0.1:9515/wd/hub/session/23865a2b1a7d285514a579c17653139b/element/0.30240034498274326-4/click] with body: {"id":"0.30240034498274326-4"}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"23865a2b1a7d285514a579c17653139b","status":0,"value":null}
info: JSONWP Proxy: Replacing sessionId 23865a2b1a7d285514a579c17653139b with 23865a2b1a7d285514a579c17653139b
info: <-- POST /wd/hub/session/23865a2b1a7d285514a579c17653139b/element/0.30240034498274326-4/click 200 1059.527 ms - 72
info: [debug] Didn't get a new command in 60 secs, shutting down...