RE: URL is not passing in cross browser testing code selenium

i am trying to write code for testing on two, chrome and Firefox browser, both browser gets open but the URL is not getting passed in that.
need help to work further, thank in advance.


WebDriver driver;

    @BeforeTest
    @Parameters("browser")

    public void setup(String browser) throws Exception {

        if (browser.equalsIgnoreCase("firefox")) {

            driver = new FirefoxDriver();

            driver.manage().window().maximize();

        } else if (browser.equalsIgnoreCase("chrome")) {

            System.setProperty("webdriver.chrome.driver", "E:\\disha.shah/myWork/eclipse/chromedriver.exe");
            driver = new ChromeDriver();

            driver.manage().window().maximize();


        } else {
            throw new Exception("Browser is not correct");

        }

        // driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    }

    @Test
    @Parameters({ "username", "password" })
    public void login(String username, String password) throws InterruptedException {

        driver.get("url goes here");
        driver.findElement(By.id("UserName")).sendKeys(username);
        driver.findElement(By.id("Password")).sendKeys(password);
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        driver.findElement(By.id("btnLogin")).sendKeys(Keys.RETURN);
    }
}
 

Here is XML


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

<suite name="Sample Test Suite" verbose="3" thread-count="2"
    parallel="methods">
    <test name="ChromeTest">

        <parameter name="browser" value="Chrome" />
        <classes>
            <class name="testngDemo.Login">
                <methods>
                    <include name="setup"></include>
                </methods>
            </class>
        </classes>

    </test>

    <test name="FirefoxTest">
        <parameter name="browser" value="Firefox" />
        <classes>
            <class name="testngDemo.Login">
                <methods>
                    <include name="setup"></include>
                </methods>
            </class>
        </classes>
    </test>

    <test name="Login Test">
        <parameter name="username" value="dishashah" />
        <parameter name="password" value="disha1234" />
        <classes>
            <class name="testngDemo.Login">
                <methods>
                    <include name="login"></include>

                </methods>
            </class>
        </classes>
    </test>
</suite>

 
disha Default Asked on March 23, 2016 in Selenium WebDriver.
Add Comment
1 Answers

Disha please update the code and XML. Formatting has complete gone haywire.

Professor Answered on March 25, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.