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

问题描述 投票:0回答:1

我可以使用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(“[email protected]”); 。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]”))点击();了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

谢谢

appium hybrid-mobile-app
1个回答
0
投票

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.