开发者

Presever-order=true does not work in selenium-grid

@BeforeTest
@Parameters({"selenium.host", "selenium.port", "selenium.browser", "selenium.url" })
public void startServer(String host, String port, String browser, String url) throws Exception {      
        selenium = new DefaultSelenium(host, Integer.parseInt(port), browser, url);
        selenium.start();
    }

testng.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="SL-Grid" parallel="false">

    <parameter name="username" value="test" />
    <parameter name="password" value="test1" /> 

<test name="SL-Chrome" preserve-order="true"> 
    <parameter name="selenium.host" value="localhost"></parameter> 
        <parameter name="selenium.port" value="5555"></parameter> 
        <parameter name="selenium.browser" value="*googlechrome"></parameter> 
        <parameter name="selenium.url" value="http://properurl:8080/"></parameter> 
        <classes>
            <class name="com.TestBase" /> // Base class where all generic methods, setUp and tearDown methods present
            <class name="com.Login"> // Login related metho开发者_如何学运维ds and inherit TestBase
                <methods>
                    <include name="loginPage" />
                    <include name="signIn" />
                </methods>
            </class>
            <class name="com.Page1">
                <methods>               
                    <include name="clickLinkA" />
                    <include name="isTextBoxXXXPresent" />
</methods> </class></classes></test>

<test name="SL-Firefox" preserve-order="true"> 
    <parameter name="selenium.host" value="172.16.4.21"></parameter> 
        <parameter name="selenium.port" value="5556"></parameter> 
        <parameter name="selenium.browser" value="*firefox"></parameter> 
        <parameter name="selenium.url" value="http://properurl:8080/"></parameter> 
        <classes>
            <class name="com.TestBase" /> // Base class where all generic methods, setUp and tearDown methods present
            <class name="com.Login"> // Login related methods and inherit TestBase
                <methods>
                    <include name="loginPage" />
                    <include name="signIn" />
                </methods>
            </class>
            <class name="com.Page2">
                <methods>               
                    <include name="clickLinkB" />
                    <include name="isListBoxXXXPresent" />
</methods> </class></classes></test>

</suite>

When i run the suite it should invoke startServer() from TestBase -> loginPage() and SignIn() from Login -> clickLinkA() and isTextBoxXXXPresent() from Page1. But manytimes system first invokes mathods from Page1 class and so gets failed (since signIn is not invoked).

Can any one please tell me where i am wrong here. Or any other better way to design. or any alternate for preserve-order


I think this may be issue in TestNG which you can report to TestNg guys. But to overcome your issue, you can include your login & Signin method in your BeforeTest or call it in your test Method in this case clickLinkA. Hope this solves your prblm.


Consider using dependsOnMethods to make sure that one test that depends on another runs after it. You can also set a numeric priority, where the lower numbers run first. The default for priority is 0, so you would only need to set this for tests to run after those that do not have a priority set.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜