0

我无法切换到 AndroidDriver 内的 iframe。详情如下。我已经尝试使用 firefox 使用常规 webdriver,并且我能够很好地切换。

代码:

require "selenium-webdriver"
require "selenium/client"

include Selenium::WebDriver::DriverExtensions::HasTouchScreen

caps = Selenium::WebDriver::Remote::Capabilities.android
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 480
driver = Selenium::WebDriver.for(
  :remote,
  :url => "http://localhost:8080/wd/hub",
  :http_client => client,
  :desired_capabilities => caps)

driver.navigate.to "some page with iframe"

driver.switch_to.frame "engagement-iframe"

堆栈跟踪:

Selenium::WebDriver::Error::UnknownError: Error: {"message":"Cannot read property 'document' of undefined"}
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: os.name: 'Linux', os.arch: 'armv7l', os.version: '3.0.31-789635', java.version: '0'
Driver info: driver.version: AndroidWebDriver (org.openqa.selenium.WebDriverException)
    from [remote server] org.openqa.selenium.android.library.AndroidWebDriver(AndroidWebDriver.java):997:in `throwIfError'
    from [remote server] org.openqa.selenium.android.library.AndroidWebDriver(AndroidWebDriver.java):868:in `executeRawScript'
    from [remote server] org.openqa.selenium.android.library.AndroidWebDriver(AndroidWebDriver.java):858:in `access$7'
    from [remote server] org.openqa.selenium.android.library.AndroidWebDriver$AndroidTargetLocator(AndroidWebDriver.java):679:in `frame'
    from [remote server] org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringTargetLocator(EventFiringWebDriver.java):573:in `frame'
    from [remote server] org.openqa.selenium.remote.server.handler.SwitchToFrame(SwitchToFrame.java):52:in `call'
    from [remote server] org.openqa.selenium.remote.server.handler.SwitchToFrame(SwitchToFrame.java):1:in `call'
    from [remote server] java.util.concurrent.FutureTask$Sync(FutureTask.java):305:in `innerRun'
    from [remote server] java.util.concurrent.FutureTask(FutureTask.java):137:in `run'
    from [remote server] org.openqa.selenium.remote.server.DefaultSession$1(DefaultSession.java):151:in `run'
    from [remote server] java.util.concurrent.ThreadPoolExecutor(ThreadPoolExecutor.java):1076:in `runWorker'
    from [remote server] java.util.concurrent.ThreadPoolExecutor$Worker(ThreadPoolExecutor.java):569:in `run'
    from [remote server] java.lang.Thread(Thread.java):856:in `run'
4

1 回答 1

0

我在测试中遇到了同样的问题,我猜这种行为会在 ChromeDriver 上重现。

我的解决方法(一个丑陋的解决方法)是将 iframe 视为一个独立的窗口。

很高兴听到您对此 WebDriver 错误的解决方案

于 2013-06-07T11:03:16.923 回答