如何在selenium webdriver

时间:2018-02-21 21:24:43

标签: selenium-webdriver parallel-processing testng

我创建了一个Parallel套装并添加了firefox,chrome等参数。我的问题是,当我运行套装时,它会记录第一次运行的结果。例如,如果我正在进行跨浏览器,那么我的测试将在firefox中运行,并且chrome首先触发firefox。问题是结果日志仅显示给火狐驱动程序。以下是我的代码。请有人建议。

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Cross Browser Testing" parallel="tests" thread-count="2">
<test name="Firefox Test">
<parameter name="browser" value="firefox"></parameter>
    <classes>
        <class name="mwgToQuotients.ResponsiveHeaderFooter1"></class>
    </classes>
</test>
<test name="Chrome Test">
<parameter name="browser" value="chrome"></parameter>
    <classes>
        <class name="mwgToQuotients.ResponsiveHeaderFooter1"></class>
    </classes>
</test>

</suite>


@BeforeClass
    @Parameters({ "browser" })
    public void setUp(String browser) {
        report = new ExtentReports("C:\\Users\\aaarb00\\Desktop\\Quotients\\MWG Reports\\QuotientCrossBrowser.html");
        test = report.startTest("Functional Test");
        baseURL = "http://ngcp-qi.safeway.com/";

        if (browser.equalsIgnoreCase("firefox")) {
            System.setProperty("webdriver.gecko.driver",
                    "C:\\Users\\aaarb00\\Desktop\\Quotients\\lib\\geckodriver.exe");
            driver = new FirefoxDriver();
            hp = new HomePage(driver, test);
            lp = new SignInPage(driver, test);
            sl = new StoreLocatorPage(driver);
            wa = new WeeklyAdPage(driver, test);
        } else if (browser.equalsIgnoreCase("chrome")) {
            System.setProperty("webdriver.chrome.driver",
                    "C:\\Users\\aaarb00\\Desktop\\Quotients\\lib\\chromedriver.exe");
            driver = new ChromeDriver();
            hp = new HomePage(driver, test);
            lp = new SignInPage(driver, test);
            sl = new StoreLocatorPage(driver);
            wa = new WeeklyAdPage(driver, test);
        }
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get(baseURL);

0 个答案:

没有答案