首页
学习
活动
专区
圈层
工具
发布

QAF _
EN

Stack Overflow用户
提问于 2021-10-03 07:04:06
回答 1查看 144关注 0票数 1

使用"switchDriver“在网络和移动之间切换。当我在web和web之间切换驱动程序(例如: Chrome到Firefox或副Versa)时,驱动程序实例是并行的,但是当我在Web和Mobile或副Versa之间切换驱动程序时,它并不是并行地保存驱动实例。

注意:我使用的是两个不同的服务提供商。浏览器堆栈(Browser堆栈)和移动(ExperiTest)。

代码语言:javascript
复制
@QAFTestStep(description = "I switch driver {drivername}") 
public static void iSwitchDriver(String drivername) {

if (drivername.equals("appiumDriver")) {
            getBundle().setProperty("remote.server","https://experitest/xxxx");
        } else { // chromeRemoteDriver/firefoxRemoteDriver/edgeRemoteDriver
            getBundle().setProperty("remote.server","https://browserstack/xxxx");
        }
        switchDriver(drivername); 
}

从Web切换到Mobile时的一些执行日志

代码语言:javascript
复制
11:53:23.937 [TestNG] INFO  c.q.q.a.step.TestStepListener - Invoking Teststep: And I take screenshot
11:53:23.938 [TestNG] INFO  c.q.q.a.ui.WebDriverCommandLogger - Executing screenshot parameters: {}
11:53:24.367 [TestNG] DEBUG c.q.qaf.automation.core.QAFTestBase - Capturing screen shotTest1_Test_EribankScenario_ntqee73ykjnh52.png
11:53:24.367 [TestNG] DEBUG c.q.qaf.automation.core.QAFTestBase - Info: 
11:53:24.367 [TestNG] INFO  c.q.q.a.step.TestStepListener - Completed Teststep: And I take screenshot
11:53:24.373 [TestNG] INFO  c.q.q.a.step.TestStepListener - Invoking Teststep: Given I switch driver "appiumDriver" with arguments: [appiumDriver]
11:53:24.374 [TestNG] INFO  c.q.q.a.ui.WebDriverCommandLogger - Executing quit parameters: {}
11:53:24.474 [TestNG] INFO  c.q.q.a.ui.WebDriverCommandLogger - command: quit[ param-1: {}] Result: null
11:53:24.474 [TestNG] INFO  c.q.q.automation.ui.UiDriverFactory - UI-driver tear down complete...
11:53:24.474 [TestNG] INFO  c.q.q.a.step.TestStepListener - Invoking Teststep: switch to {driverName} with arguments: [appiumDriver]
11:53:24.475 [TestNG] INFO  c.q.q.a.step.TestStepListener - Completed Teststep: switch to {driverName} with arguments: [appiumDriver]
11:53:24.475 [TestNG] INFO  c.q.q.a.step.TestStepListener - Completed Teststep: Given I switch driver "appiumDriver" with arguments: [appiumDriver]
11:53:24.489 [TestNG] INFO  c.q.q.a.step.TestStepListener - Invoking Teststep: Given I assert "Mobile.login.button" is present with arguments: [Mobile.login.button]
11:53:24.489 [TestNG] INFO  c.q.q.a.step.TestStepListener - Invoking Teststep: assert {loc} is present with arguments: [Mobile.login.button]
Driver not configured!... 
Using firefoxDriver as default value. Please configure driver to be used using 'driver.name' property
11:53:24.490 [TestNG] INFO  c.q.qaf.automation.core.QAFTestBase - Initializing Driver...browser_str:appiumDriver,base_url:http://www.google.com/,sel_server:https://experitest.com/wd/hub,port:4444
11:53:24.490 [TestNG] INFO  c.q.q.automation.ui.UiDriverFactory - Driver: appiumDriver
Oct 03, 2021 11:54:21 AM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: OSS
11:54:21.718 [TestNG] INFO  c.q.qaf.automation.core.QAFTestBase - driver init done
11:54:21.719 [TestNG] INFO  c.q.q.a.ui.WebDriverCommandLogger - Executing findElements parameters: {"value":"//*[@id='loginButton']","using":"xpath"}

从Mobile到Web交换的一些执行日志:

代码语言:javascript
复制
1:54:31.317 [TestNG] INFO  c.q.q.a.step.TestStepListener - Completed Teststep: Given I assert "Mobile.login.button" is present with arguments: [Mobile.login.button]
11:54:31.323 [TestNG] INFO  c.q.q.a.step.TestStepListener - Invoking Teststep: Given I switch driver "firefoxRemoteDriver" with arguments: [firefoxRemoteDriver]
11:54:31.324 [TestNG] INFO  c.q.q.a.ui.WebDriverCommandLogger - Executing quit parameters: {}
11:54:38.295 [TestNG] INFO  c.q.q.a.ui.WebDriverCommandLogger - command: quit[ param-1: {}]
11:54:38.296 [TestNG] INFO  c.q.q.automation.ui.UiDriverFactory - UI-driver tear down complete...
11:54:38.296 [TestNG] INFO  c.q.q.a.step.TestStepListener - Invoking Teststep: switch to {driverName} with arguments: [firefoxRemoteDriver]
11:54:38.296 [TestNG] INFO  c.q.q.a.step.TestStepListener - Completed Teststep: switch to {driverName} with arguments: [firefoxRemoteDriver]
11:54:38.296 [TestNG] INFO  c.q.q.a.step.TestStepListener - Completed Teststep: Given I switch driver "firefoxRemoteDriver" with arguments: [firefoxRemoteDriver]
11:54:38.298 [TestNG] INFO  c.q.q.a.step.TestStepListener - Invoking Teststep: Given I open "https://demobank1.xxxxx.com/" with arguments: [https://demobank1.xxxxx.com/]
Driver not configured!... 
Using firefoxDriver as default value. Please configure driver to be used using 'driver.name' property
11:54:38.299 [TestNG] INFO  c.q.qaf.automation.core.QAFTestBase - Initializing Driver...browser_str:firefoxRemoteDriver,base_url:http://www.google.com/,sel_server:https://browserstack.com/grid1/wd/hub,port:4444
11:54:38.299 [TestNG] INFO  c.q.q.automation.ui.UiDriverFactory - Driver: firefoxRemoteDriver
Oct 03, 2021 11:54:42 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
11:54:42.900 [TestNG] INFO  c.q.qaf.automation.core.QAFTestBase - driver init done
11:54:42.900 [TestNG] INFO  c.q.q.a.ui.WebDriverCommandLogger - Executing maximizeCurrentWindow parameters: {}
11:54:43.222 [TestNG] INFO  c.q.q.a.ui.WebDriverCommandLogger - command: maximizeCurrentWindow[ param-1: {}] Result: {x=0, y=0, width=1920, height=1055}
11:54:43.222 [TestNG] INFO  c.q.q.a.step.TestStepListener - Invoking Teststep: get {url} with arguments: [https://demobank1.xxxxx.com/]

应用程序能力:

代码语言:javascript
复制
appium.capabilities.accessKey=asdljj.sdasdad.asdasdasd.asd
appium.capabilities.uuid=asdsd23424
appium.capabilities.platformName=android
appium.capabilities.app=cloud:com.xxxx.xxx/.LoginActivity
appium.capabilities.instrumentApp=true
appium.capabilities.appPackage=com.xxx.xxx
appium.capabilities.appActivity=com.xxx.xxx.LoginActivity
appium.capabilities.driverClass=io.appium.java_client.android.AndroidDriver

浏览器功能:

代码语言:javascript
复制
chrome.additional.capabilities={'name': 'Chrome - Test Run','browserName': 'chrome', 'browserVersion': '89.0' }

我已经尝试过引用下面的解决方案链接:在量规中在驱动程序之间来回切换如何在TestNG XML文件中配置一个测试以启动两个驱动程序,比如使用QAF时的Chrome驱动程序和Android驱动程序

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-06 17:13:30

通过设计qaf拆卸驱动实例,观察到任何驱动程序特定属性的变化.您可以通过删除配置监听器来尝试。

代码语言:javascript
复制
    ConfigurationManager.getBundle().clearConfigurationListeners();

它可能会影响资源负载行为。

要克服这个问题,您可以使用驱动程序特定资源特性,它允许您创建单独的属性、文件/文件夹,并将其设置为驱动程序资源。这样,在更改驱动程序时,不需要为加载资源编写代码。例如:

代码语言:javascript
复制
env.name=qa
env.resources=resources/common;resources/${env.name}
driver.name=androidRemoteDriver

android.resources=resources/android;resources/mobilecloude.properties
ios.resources=resources/ios;resources/mobilecloude.properties
chrome.resources=resources/web;resources/browsercloude.properties
firefox.resources=resources/web;resources/browsercloude.properties
edge.resources=resources/web;resources/browsercloude.properties

在上面的例子中,

  • 如果android/ios/桌面-web的定位器不同,resources/webresources/androidresources/ios可能包含定位器存储库。
  • resources/${env.name}可能包含特定于环境的资源。例如,特定于环境的测试数据。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69422761

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档