总配置

application.properties

env.resources=src/main/resources/common #配置resource文件所在目录,如.loc定位文件
resources.load.subdirs=2 #配置加载子目录层次
scenario.file.loc=src/main/resources/scenarios #配置场景.feature文件目录
step.provider.pkg=com.quantum.steps #配置自定义关键字包
driver.name=chromeDriver #配置driver的名称
webdriver.chrome.driver=D:/xx/xx/chromedriver.exe #配置diver位置
driver.pluginType=intellij #指定IDE
driver.init.retry.timeout=60 #指定timeout
selenium.wait.timeout=15000 #指定wait.timeout
selenium.success.screenshots=0 #指定成功是否截图
wd.command.listeners=com.quantum.listeners.PerfectoDriverListener #指定监听器
teststep.listeners=com.quantum.listeners.QuantumReportiumListener #指定监听器

##When enabled your test will be retried from the start
##customizations can be made to your own personal retry analyzer - please see the documentation on our github wiki page
##https://github.com/Project-Quantum/Quantum-Starter-Kit/wiki
#retry.count=1
#retry.analyzer=com.quantum.utils.Retry

##user proxy for API calls - enable this and set you proxy details 
##if you encounter unexpected errors when downloading perfecto reports
#proxyHost=127.0.0.1
#proxyPort=8888
#proxyUser=1
#proxyPassword=1

##enable to turn on parallel data providers
##you must also define in testNg.xml the data provider thread count
##<suite name=....... data-provider-thread-count="10">
#global.datadriven.parallel=true

##set true to fill bean randomly from set of test-data
#bean.populate.random=false

##set 1 to suppress success log, when 0 it will also show verification success message
report.log.skip.success=0

##Use this key to add test data in the scenario names for Reportium results
#addFullDataToReport=true

##Use this key to pass the skipped tests, by default all the skipped tests will be marked as fail in reportium
#skippedTests=pass

#perfecto.capabilities.user=yourname@xxx.com
##generate the security token using this document - https://developers.perfectomobile.com/display/PD/Security+Token
#perfecto.capabilities.securityToken=<<XX_XX_SECURITY_TOKEN>>
#perfecto.capabilities.password=yourpassword
#perfecto.capabilities.automationName=Appium
#perfecto.capabilities.browserName=MobileOS

##switch download reports true/false to download reports.
#perfecto.download.reports=false
#perfecto.download.summaryReports=false
#perfecto.download.video=false
#perfecto.download.attachments=false
#perfecto.report.location= perfectoReports
#perfecto.offlineToken= <<CQ_LAB_SECURITY_TOKEN>>

在指定的步骤包中自定义步骤(关键字)

	@Then("I switch to \"(.*?)\" frame by element")
	public static void switchToFrameByElement(String loc) {
		new WebDriverTestBase().getDriver().switchTo().frame(new QAFExtendedWebElement(loc));
	}

在指定的resource文件夹中编写.loc元素定位文件

#input.box = xpath=//input[@id='kw']
input.box = id=kw
#search.button=["xpath=//input[@id='su']","xpath=//button[@aria-label='Baidu Search']"]
search.button = ["xpath=//input[@id='su']"]

在指定的场景目录中编写.feature文件

@BaiduSearch
Feature: Baidu Search
  Scenario: Search CSDN
    Given I open browser to webpage "https://www.baidu.com/"
    Then I enter "CSDN" to "input.box"
    Then I click on "search.button"
    Then I wait for "5" seconds

配置TestNG的xml文件

在TestNG的xml文件中调用@BaiduSearch注解,同时可修改application.properties中的属性,如.loc的目录

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Baidu Search Demo Suite" verbose="0" parallel="tests"
       thread-count="100">
    <listeners>
        <listener class-name="com.quantum.listeners.QuantumReportiumListener"/>
    </listeners>

    <test name="Web Scenarios Test" enabled="true" thread-count="10">
        <parameter name="env.resources" value="src/main/resources/baidu"/>
        <groups>
            <run>
                <include name="@BaiduSearch"/>
            </run>
        </groups>
        <classes>
            <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory"/>
        </classes>
    </test>
</suite>

Refer

https://blog.csdn.net/Cupupup/article/details/80154544

posted on 2019-07-12 16:08  liehen2046  阅读(267)  评论(0编辑  收藏  举报