selenium - Appium can not operate the element -
i'm using below code test android app appium, when try operate element
driver.findelementbyid("com.tdmobile.ipems_app:id/login_ipaddress_edit").sendkeys("http://192.168.0.71:8080/ipems/");
i got java.lang.nullpointerexception
, when debug line, find element not null, know happened?
androiddriver driver = null; desiredcapabilities cap = new desiredcapabilities(); cap.setcapability("automationname", "appium");//appium做自动化 cap.setcapability("app", "c:\\users\\baiming.zhang\\desktop\\ipems-app.apk"); cap.setcapability("devicename", "xiaomi-mi_5");//设备名称 cap.setcapability("platformname", "android"); //安卓自动化还是ios自动化 cap.setcapability("platformversion", "6.0"); //安卓操作系统版本 cap.setcapability("udid", "794b155c"); //设备的udid (adb devices 查看到的) cap.setcapability("unicodekeyboard", "true"); //支持中文输入 cap.setcapability("resetkeyboard", "true"); //支持中文输入,必须两条都配置 cap.setcapability("nosign", "true"); //不重新签名apk driver = new androiddriver(new url("http://0.0.0.0:4723/wd/hub"),cap);//把以上配置传到appium服务端并连接手机 driver.manage().timeouts().implicitlywait(10, timeunit.seconds);//隐式等待 driver.findelementbyid("com.tdmobile.ipems_app:id/login_ipaddress_edit").sendkeys("http://192.168.0.71:8080/ipems/");//this line failed. driver.findelementbyid("com.tdmobile.ipems_app:id/login_user_edit").sendkeys("http://192.168.0.71:8080/ipems/"); driver.findelementbyid("com.tdmobile.ipems_app:id/login_passwd_edit").sendkeys("http://192.168.0.71:8080/ipems/"); driver.findelementbyid("com.tdmobile.ipems_app:id/login_login_btn").click();
the complete stacktrace is:
exception in thread "main" java.lang.nullpointerexception @ org.openqa.selenium.remote.remotewebelement.execute(remotewebelement.java:275) @ org.openqa.selenium.remote.remotewebelement.isdisplayed(remotewebelement.java:316) @ simple.calculatortest.main(calculatortest.java:47)
a recent selenium update version 3.5.1 seems have broken appium's java client.
further information here.
although thread refers appium's java client 5.0.0-beta9, know @ least versions 4.1.x broken, because happened me.
so, current workaround force selenium's version 3.4.0, so:
compile ('org.seleniumhq.selenium:selenium-api:3.4.0'){force = true} compile ('org.seleniumhq.selenium:selenium-remote-driver:3.4.0'){force = true} compile ('org.seleniumhq.selenium:selenium-support:3.4.0'){force = true}
it worked me.
Comments
Post a Comment