在混合应用程序中,将本机切换到webview后,选择器将不工作

kokeuurv  于 2021-08-20  发布在  Java
关注(0)|答案(0)|浏览(216)

我正在运行browserstack应用程序自动化,其中应用程序同时包含本机上下文和webview。在将本机切换到webview后,我遇到了此异常。webselector不工作的地方。

try {

            driver = new Android Driver<AndroidElement>(new URL(URL), capabilities);
            System.out.println("APPIUM driver initiated : " + driver);
            ((WebDriver) driver).manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS) ;
            System.out.println(((AppiumDriver<AndroidElement>) driver).getContext());
            ((AppiumDriver<AndroidElement>) driver).context("NATIVE_APP");
             driver.findElementByAccessibilityId("START NOW").click();
            System.out.println("Clicked on Start now");
            ((AppiumDriver<AndroidElement>) driver).context("WEBVIEW");
            System.out.println(((AppiumDriver<AndroidElement>) driver).getContext());
             Thread.sleep(3000);
           driver.findElement(By.id("'studentLogin_userMailId")).sendKeys("sahfgdfgsdfhsdg@gmail.com");
            driver.findElement(By.xpath("studentLoginsubmit")).click();
       Thread.sleep(3000);
       System.out.println(((AppiumDriver<AndroidElement>) driver).getContext());            
                        }
            catch(Exception e) {
                  e.printStackTrace();
                    }

                    finally {
                     driver.quit();
                    }

                }
enter code here

有一个例外:我曾尝试使用XPathIDCSS名称,但仍然面临这个问题。
org.openqa.selenium.nosuchelementexception:没有这样的元素:无法找到元素:{“方法”:“id”,“选择器”:“studentlogin\u usermailid”}
(会话信息:chrome=89.0.4389.105)(驱动程序信息:chromedriver=89.0.4389.23(61b08ee2c50024bab004e48d2b1b083cdbdac579参考/branch heads/4389@{294}),platform=linux 4.1.13-101.fc21.x86_64 x8664)(警告:服务器未提供任何stacktrace信息)命令持续时间或超时:0毫秒,用于记录此错误,请浏览:https://www.seleniumhq.org/exceptions/no_such_element.html 构建信息:版本:'3.141.59',版本:'e82be7d358',时间:'2018-11-14t08:25:48'系统信息:主机:'desktop-crovb78',ip:'192.168.43.130',os.name:'windows 10',os.arch:'amd64',os.version:'10.0',java.version:'15.0.2'驱动程序信息:io.appium.java_client.android.android驱动程序功能{64位:false,acceptsslcert:false,acceptsslcerts:false,adbexectimeout:120000,appactivity:com.englishhelp.readtome…,apppackage:com…,appurl:bs://…,autowebview:true,automationname:uiautomator2,browserstack.appium版本:1.17.0,browserstack.is_hub_canary:false,browserstack.minosversion:6.0,buildname:rtms,bundleid:com.ereadtome….,bundleid:coe….,chromeoptions:{w3c:false},chromedriverport:18084,chromedriverport:1814418154,数据库启用:false,检测到的语言:selenium/3.141.59(java win…,设备:google pixel 3,DevicePilevel:29,devicemanufacturer:google,devicemodel:pixel 3,devicename:8bmx1cpet,deviceorientation:potrait,DeviceCredensity:440,devicescreensize:1080x2160,DeviceAudid:8bmx1cpet,enableperformancelogging:false,javascriptenabled:true,locationcontextenabled:false,mobile:{browser:mobile,version:google pixel 3-10.0},nativewebscreenshot:true,networkconnectionenabled:true,newcommandtimeout:0,new_bucketing:true,orig_os:android,像素比率:2.75,平台:android,平台名称:android,平台版本:10,realmobile:true,real_mobile:true,SkipServer安装:true,statbarheight:66,系统端口:8204,takesscreenshot:true,udid:8bmx1cpet,uiautomator2serverlaunchtimeout:60000,版本:,viewportrect:{高度:1962,左侧:0,顶部:66,宽度:1080},警告:{},WebStorage Enabled:false}会话id:bd62fbded6c4165b7b54ba80b5e6f2c950d5c2e9***元素信息:{using=id,java.base/jdk.internal.reflect.nativeconstructoraccessorimpl.newinstance0(本机方法)处的value='studentlogin\u usermailid}位于java.base/jdk.internal.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:64)处java.base/java.lang.reflect.constructor.newinstancewithcaller(constructor.java:500)处的java.base/java.lang.reflect.constructor.newinstancewithcaller(constructor.java:500)处的java.base/java.lang.reflect.constructor.newinstance(delegatingconstructororaccessorimpl.java:45)org.openqa.selenium.remote.errorhandler.createthrowable(errorhandler.java:214)位于org.openqa.selenium.remote.errorhandler.throwifresponsefailed(errorhandler.java:166)位于org.openqa.selenium.remote.http.AbstractHttpResponseDec.decode(AbstractHttpResponseDec.java:80)在org.openqa.selenium.remote.http.AbstractHttpResponseDec.decode(AbstractHttpResponseDec.java:44)在org.openqa.selenium.remote.httpcommandexecutor.execute(httpcommandexecutor.java:158)在io.appium.java_client.remote.appiumcommandexecutor.execute(appiumcommandexecutor.java:239)位于org.openqa.selenium.remote.remotewebdriver.execute(remotewebdriver.java:552)位于io.appium.java_client.defaultgenericmobiledriver.execute(defaultgenericmobiledriver.java:41)位于io.appium.java_client.appiumdriver.execute(appiumdriver.java:1)位于io.appium.java_client.android.androiddriver.execute(androiddriver.java:1)位于org.openqa.selenium.remote.remotewebdriver.findelement(remotewebdriver.java:323)位于io.appium.java_client.defaultgenericmobiledriver.findelement(defaultgenericmobiledriver.java:61)位于io.appium.java

_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
    at

org.openqa.selenium.remote.remotewebdriver.findelementbyid(remotewebdriver.java:372)在io.appium.java\u client.defaultgenericmobiledriver.findelementbyid(defaultgenericmobiledriver.java:69)在io.appium.java\u client.appiumdriver.findelementbyid(appiumdriver.java:1)在io.appium.java\u client.androiddriver.findelementbyid(androiddriver.java:1)上在org.openqa.selenium.by$byid.findelement(by.java:188)在org.openqa.selenium.remote.remotewebdriver.findelement(remotewebdriver.java:315)在io.appium.java_client.defaultgenericmobiledriver.findelement(defaultgenericmobiledriver.java:57)在io.appium.java_client.appiumdriver.findelement(appiumdriver.java:1)在testing.newapplaunch.main(newapplaunch.java:47)中的io.appium.java_client.android.androiddriver.findelement(androiddriver.java:1)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题