Selenium无法在firefox android应用上找到插件按钮。我已经尝试了id和xpath定位器。
这是代码段:
// driver is an instance of AndroidDriver
driver.navigate().to("about:addons");
Thread.sleep(5000);
WebElement mainLayout = driver.findElementById("org.mozilla.firefox:id/main_layout");
System.out.println("#" + mainLayout.getText());
WebElement addonsList = driver.findElementById("addons-list");
System.out.println("@" + addonsList);
MobileElement randomUserAgent = (MobileElement) addonsList.findElement(By.xpath("//android.widget.Button[5]"));
System.out.println(randomUserAgent);
我能够打开插件页面,但是此后我得到以下错误(无法找到ID为“ addons-list”的元素):
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.
任何人都可以帮助我找到并点击加载项按钮。 谢谢
答案 0 :(得分:0)
我宁愿以另一种方式在移动Firefox上更改用户代理:通过手动更改浏览器的首选项:
about:config
general.useragent.overridepreference
更多详细信息here。