Safari浏览器:切换到框架无效

时间:2017-10-12 09:31:21

标签: selenium selenium-webdriver webdriver browserstack safaridriver

我正在尝试对移动仿真器(Safari浏览器)进行少量测试并遇到问题。切换到Iframe后,我无法采取任何行动。

已经有一个已经关闭的问题,但是在通过这个帖子之后我没有找到任何解决方案。

https://github.com/appium/appium/issues/5832

导致问题的代码

 public PaymentPage fillCreditCardInformation(String cardNumber, String expiryDate, String cvv, String postal ){
        switchToPaymentFrame();
        WebElement cardNumberEditbox = driver.findElement(By.name("cardnumber"));
}

private void switchToPaymentFrame() {
    WebElement frame = driver.findElement(By.name("__privateStripeFrame3"));
    driver.switchTo().frame(frame);
}

使用的仿真器:Iphone 6s,IPad Mini Webdriver版本:3.4.0 Safari驱动程序:2.48

Stacktrace:

  

org.openqa.selenium.WebDriverException:undefined不是对象   (评估'a.querySelectorAll')(警告:服务器没有提供   任何堆栈跟踪信息)命令持续时间或超时:30.48秒   构建信息:版本:'3.4.0',修订版:'未知',时间:'未知'   系统信息:主机:'DL0019',ip:'127.0.1.1',os.name:'Linux',   os.arch:'amd64',os.version:'4.4.0-96-generic',java.version:   '1.8.0_131'驱动程序信息:org.openqa.selenium.remote.RemoteWebDriver   能力[{noReset = true,safari = true,   browserstack.tunnelIdentifier =,browserstack.asyncStop = true,   language = Apache-HttpClient / 4.5.3(Java / 1.8.0_131),   browserstack.selenium_version = 3.4.0,deviceName == iPad Retina(9.1)   [556DF534-C4AE-48B6-8ED3-BAF86198074A],平台= MAC,   browserstack.video.disableWaterMark = true,desired = {noReset = true,   browserstack.tunnelIdentifier =,browserstack.asyncStop = true,   language = Apache-HttpClient / 4.5.3(Java / 1.8.0_131),   browserstack.selenium_version = 3.4.0,deviceName == iPad Retina(9.1)   [556DF534-C4AE-48B6-8ED3-BAF86198074A],平台= MAC,   browserstack.video.disableWaterMark = true,acceptSslCerts = false,   newCommandTimeout = 300.0,browser = ipad,platformVersion = 9.1,   acceptSslCert = false,browserName = safari,platformName = iOS,   64bit = false,browserstack.debug = true,orientation = portrait,   browserstack.ie.noFlash = false,os_version =,   mobile = {“browser”:“tablet”,“version”:“iPad Mini 4-9.1”},   browserstack.geckodriver = 0.16.0,version =,browserstack.video = true,   safariIgnoreFraudWarning = true,orig_os = macelc,realMobile = false,   deviceOrientation = PORTRAIT,device = iPad Retina,proxy_type = node},   acceptSslCerts = false,newCommandTimeout = 300.0,browser = ipad,   platformVersion = 9.1,webStorageEnabled = false,acceptSslCert = false,   browserName = safari,takesScreenshot = true,javascriptEnabled = true,   platformName = iOS,64bit = false,browserstack.debug = true,   networkConnectionEnabled = false,orientation = portrait,   browserstack.ie.noFlash = false,warnings = {},os_version =,   mobile = {“browser”:“tablet”,“version”:“iPad Mini 4-9.1”},   browserstack.geckodriver = 0.16.0,databaseEnabled = false,version =,   browserstack.video = true,safariIgnoreFraudWarning = true,   orig_os = macelc,realMobile = false,locationContextEnabled = false,   deviceOrientation = PORTRAIT,device = iPad Retina,proxy_type = node}]   会话ID:6bf643515813d0ccbe5fe75300ac2d8ea15a5960   ***元素信息:{使用=名称,值=卡号}

2 个答案:

答案 0 :(得分:0)

你可以试试这个:

变化:

private void switchToPaymentFrame() {
    WebElement frame = driver.findElement(By.name("__privateStripeFrame3"));
    driver.switchTo().frame(frame);
}

要:

private void switchToPaymentFrame() {
    WebDriverWait wait1 = new WebDriverWait(driver, 10);
    wait1.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.name("__privateStripeFrame3")));
}

答案 1 :(得分:0)

在我看来就像一个已知问题。 根本行不通。

https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/7658