无法使用appium for iOS hybrid app

时间:2015-08-06 14:42:03

标签: appium hybrid-mobile-app

我可以使用appium检查器通过appium检查元素,但页脚上的元素没有找到,因为我无法到达xpath。

我尝试使用从源代码中获取的id,但是再次"无法定位元素"我运行测试脚本时会显示消息。

  

public static void main(String [] args)抛出MalformedURLException,   InterruptedException {AppiumDriver wd; DesiredCapabilities   capabilities = new DesiredCapabilities();   capabilities.setCapability(" appium-version"," 1.0");   capabilities.setCapability(" platformName"," iOS");   capabilities.setCapability(" platformVersion"," 8.1");   capabilities.setCapability(" deviceName"," iPhone 6");   capabilities.setCapability("应用&#34 ;,   " / Users / deepak / Library / Developer / Xcode / DerivedData / AceMobile-adoppngvthizceerrugpjdqlruyj / Build / Products / Debug-iphonesimulator / ACE Banker.app"); wd =新的IOSDriver(新的   网址(" http://0.0.0.0:4723/wd/hub"),功能);   wd.manage()。timeouts()。implicitlyWait(60,TimeUnit.SECONDS);   了Thread.sleep(10000);   wd.findElement(By.xpath(" // UIAApplication 1 / {UIAWindow {3}} / {UIAScrollView {3}} / {UIAWebView {3}} / {UIATextField {3}}&# 34))点击();   了Thread.sleep(5000); ((MobileElement)   wd.findElement(By.xpath(" // UIAApplication 1 / {UIAWindow {3}} / {UIAScrollView {3}} / {UIAWebView {3}} / {UIATextField {3}}&# 34;)))的setValue(" ALMq.admin@tier1crm.com");   wd.findElement(By.name("完成&#34))。单击();了Thread.sleep(5000);   wd.findElement(By.xpath(" // UIAApplication 1 / {UIAWindow {3}} / {UIAScrollView {3}} / {UIAWebView {3}} / {UIASecureTextField {3}}&# 34))点击();   ((MobileElement)wd.findElement(By.xpath(" // UIAApplication 1 / {UIAWindow {3}} / {UIAScrollView {3}} / {UIAWebView {3}} / {UIASecureTextField {3- }}")))的setValue(" ALMqAdmin123"!);   wd.findElement(By.name("完成&#34))。单击();   //wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIAScrollView1/UIAWebView1/UIAButton1 "))点击();   了Thread.sleep(5000);   wd.findElement(By.xpath(" // UIAApplication 1 / {UIAWindow {3}} / {UIAScrollView {3}} / {UIAWebView {3}} / {UIAButton {3}}&# 34))点击();   了Thread.sleep(5000);   wd.findElement(By.xpath(" // UIAApplication 1 / {UIAWindow {3}} / {UIASecureTextField {3}}&#34))。单击();   wd.findElement(By.xpath(" // UIAApplication 1 / {UIAWindow {3}} / {UIASecureTextField {3}}&#34))的SendKeys(" 1111&#34 );   wd.findElement(By.name("接着&#34))。单击();   wd.findElement(By.xpath(" // UIAApplication 1 / {UIAWindow {3}} / {UIASecureTextField {3}}&#34))。单击();   wd.findElement(By.xpath(" // UIAApplication 1 / {UIAWindow {3}} / {UIASecureTextField {3}}&#34))的SendKeys(" 1111&#34 );   wd.findElement(By.name("完成&#34))。单击();了Thread.sleep(5000);

     

/ *我们坐在这里滚动* /

     

wd.findElement(By.xpath(" // UIAApplication 1 / {UIAWindow {3}} / {UIAScrollView {3}} / {UIAWebView {3}} / UIASwitch [8]& #34))点击();   了Thread.sleep(4000);   wd.findElement(By.xpath(" // UIAApplication 1 / {UIAWindow {3}} / {UIAScrollView {3}} / {UIAWebView {3}} / UIASwitch [14]" ))点击();   了Thread.sleep(4000);   wd.findElement(By.xpath(" // UIAApplication 1 / {UIAWindow {3}} / {UIAScrollView {3}} / {UIAWebView {3}} / UIASwitch [20]" ))点击();   了Thread.sleep(4000);   wd.findElement(By.xpath(" // UIAApplication 1 / {UIAWindow {3}} / {UIAScrollView {3}} / {UIAWebView {3}} / UIASwitch [26]" ))点击();   了Thread.sleep(4000);   wd.findElement(By.xpath(" // UIAApplication 1 / {UIAWindow {3}} / {UIAScrollView {3}} / {UIAWebView {3}} / UIASwitch [32]" ))点击();   了Thread.sleep(4000);   //wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIAScrollView1/UIAWebView1/UIASwitch[34]&# 34))点击();   了Thread.sleep(5000);

     

/ *滚动后,此元素未定位* / WebElement   element = wd.findElement(By.id(" ext-button-96"));

在页脚上方有一个可滚动的屏幕。

1

由于

1 个答案:

答案 0 :(得分:0)

Appium inspector和Ui automatorviewer将帮助获取当前android视图上的布局。(所有句柄均基于布局)。

如果需要查找视图中不存在的xpath,请尝试向下滚动查找xpath,id(locators)。

在脚本中,尝试使用滚动到文本或滚动到元素。