首页 文章

无法使用appium for iOS hybrid app检查作为背景图像呈现的元素

提问于
浏览
0

我可以使用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(“app”,“/ Users / deepak / Library / Developer / Xcode / DerivedData / AceMobile-adoppngvthizceerrugpjdqlruyj / Build / Products / Debug-iphonesimulator / ACE Banker.app”); wd =新的IOSDriver(新的URL(“http://0.0.0.0:4723/wd/hub”),功能); wd.manage() . timeouts() . implicitlyWait(60,TimeUnit.SECONDS);了Thread.sleep(10000); wd.findElement(By.xpath( “// UIAApplication1 / UIAWindow1 / UIAScrollView1 / UIAWebView1 / UIATextField1”))点击();了Thread.sleep(5000); ((MobileElement)wd.findElement(By.xpath(“// UIAApplication1 / UIAWindow1 / UIAScrollView1 / UIAWebView1 / UIATextField1”))) . setValue(“ALMq.admin@tier1crm.com”); . wd.findElement(By.name( “完成”))点击();了Thread.sleep(5000); wd.findElement(By.xpath( “// UIAApplication1 / UIAWindow1 / UIAScrollView1 / UIAWebView1 / UIASecureTextField1”))点击(); ((MobileElement)wd.findElement(By.xpath( “// UIAApplication1 / UIAWindow1 / UIAScrollView1 / UIAWebView1 / UIASecureTextField1”)))的setValue( “ALMqAdmin123!”) . . wd.findElement(By.name( “完成”))点击(); . //wd.findElement(By.xpath( “// UIAApplication1 / UIAWindow1 / UIAScrollView1 / UIAWebView1 / UIAButton1”))点击();了Thread.sleep(5000); wd.findElement(By.xpath( “// UIAApplication1 / UIAWindow1 / UIAScrollView1 / UIAWebView1 / UIAButton1”))点击();了Thread.sleep(5000); wd.findElement(By.xpath( “// UIAApplication1 / UIAWindow1 / UIASecureTextField1”))点击(); wd.findElement(By.xpath( “// UIAApplication1 / UIAWindow1 / UIASecureTextField1”))的SendKeys( “1111”) . . wd.findElement(By.name( “下一步”))点击(); wd.findElement(By.xpath( “// UIAApplication1 / UIAWindow1 / UIASecureTextField1”))点击(); wd.findElement(By.xpath( “// UIAApplication1 / UIAWindow1 / UIASecureTextField1”))的SendKeys( “1111”) . . wd.findElement(By.name( “完成”))点击();了Thread.sleep(5000); / 这里我们坐着滚动 / wd.findElement(By.xpath(“// UIAApplication1 / UIAWindow1 / UIAScrollView1 / UIAWebView1 / UIASwitch [8]”)) . click();了Thread.sleep(4000); wd.findElement(By.xpath( “// UIAApplication1 / UIAWindow1 / UIAScrollView1 / UIAWebView1 / UIASwitch [14]”))点击();了Thread.sleep(4000); wd.findElement(By.xpath( “// UIAApplication1 / UIAWindow1 / UIAScrollView1 / UIAWebView1 / UIASwitch [20]”))点击();了Thread.sleep(4000); wd.findElement(By.xpath( “// UIAApplication1 / UIAWindow1 / UIAScrollView1 / UIAWebView1 / UIASwitch [26]”))点击();了Thread.sleep(4000); wd.findElement(By.xpath( “// UIAApplication1 / UIAWindow1 / UIAScrollView1 / UIAWebView1 / UIASwitch [32]”))点击();了Thread.sleep(4000); //wd.findElement(By.xpath( “// UIAApplication1 / UIAWindow1 / UIAScrollView1 / UIAWebView1 / UIASwitch [34]”))点击();了Thread.sleep(5000); / 滚动后,此元素未定位 / WebElement element = wd.findElement(By.id(“ext-button-96”));

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

enter image description here

谢谢

1 回答

  • 0

    Appium督察和Ui automatorviewer将帮助获得当前android视图中出现的布局 . (所有句柄都基于布局) .

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

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

相关问题