【问题标题】:Operation timed out while switching to webview(NewTab) context in Appium 1.13 IOS 12.3.1在 Appium 1.13 IOS 12.3.1 中切换到 webview(NewTab) 上下文时操作超时
【发布时间】:2019-05-28 05:02:11
【问题描述】:

切换到本机弹出窗口后,单击“允许”后将不会切换到 web 视图,并且控件不会转到下一个选项卡。我得到了 Native, Webview_4,Webview_5 一样的明智。

错误堆栈跟踪:

May 28, 2019 9:36:30 AM org.openqa.selenium.support.ui.ExpectedConditions findElement WARNING: WebDriverException thrown by findElement(By.xpath: //button[@class='little130 blue']) org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Did not get any response after 20s Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:32:19.891Z' System info: host: 'local', ip: 'fe80:0:0:0:c1a:bce1:50e1:ac1d%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.4', java.version: '12' Driver info: io.appium.java_client.ios.IOSDriver Capabilities {appiumVersion:
1.9.1, autoAcceptAlerts: true, autoDismissAlerts: true, autoGrantPermissions: true, automationName: XCUITest, browserName: Safari, databaseEnabled: false, deviceName:TS, javascriptEnabled: true, locationContextEnabled: falsenetworkConnectionEnabled: false, newCommandTimeout: 2000,platform: MAC, platformName: iOS, platformVersion: 12.2, safariAllowPopups: false, startIWDP: true, takesScreenshot: true, udid: ****..., unexpectedAlertBehaviour: true, unhandledPromptBehavior: true, webStorageEnabled: false, webkitResponseTimeout: 20000, xcodeOrgId: BYKRN84M2R, xcodeSigningId: iPhone Developer} Session ID: fc7d6ca1-3901-4fb0-a001-69ff9a499308
*** Element info: {Using=xpath, value=//button[@class='little']} at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) atjava.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)atjava.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)

使用下面的代码,但它不起作用

Set<String> strcont=null; strcont=driver.getcontextHandles(); 
For(String s: strcont) {
  if(s.contains(WEBVIEW)) {
    driver.context(s); 
  } 
} catch (Exception e) {
     e.printStackTrace();
} 

【问题讨论】:

    标签: java selenium appium appium-ios


    【解决方案1】:
    After clicking the "popup" button again switch to webview,give break inside the condition find the below code
    
    Set<String> strcont=null; strcont=driver.getcontextHandles(); 
    For(String s: strcont) {
      if(s.contains(WEBVIEW)) {
        driver.context(s); 
        break;
      } 
    } catch (Exception e) {
         e.printStackTrace();
    }
    

    【讨论】:

    • 或者使用这个功能=> caps.setCapability("autoGrantPermissions", true)
    • 使用以下修改方法: Set contextNames = driver.getContextHandles(); // System.out.println(contextNames.toString()); for (String contextName : contextNames) { if (contextName.contains(viewType)) { if (contextName.contains("WEBVIEW")) { System.out.println(contextNames); System.out.println(contextNames.toArray()[contextNames.toArray().length - 1].toString()); BasePage._driver.context(contextNames.toArray()[contextNames.toArray().length - 1].toString()); } else { BasePage._driver.context(contextName); } }
    • System.out.println(contextNames); [NATIVE_APP,WEBVIEW_6,WEBVIEW_7] System.out.println(contextNames.toArray()[contextNames.toArray().length - 1].toString()); : WEBVIEW_7 得到同样的异常错误
    • 这一行显示错误:BasePage.driver.context(contextNames.toArray()[contextNames.toArray().length - 1].toString());
    • 嗨,伙计,其实我没听懂,你能详细说明一下吗
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-19
    • 2015-09-24
    • 2020-07-14
    • 2021-07-20
    • 2015-09-16
    • 2019-07-22
    • 2014-07-11
    相关资源
    最近更新 更多