Trying to use @Parameter method but click on “Login” link not working

Hi All,

I wrote a  signUp code (freecharge website) and parameterize values using @Parameter but the ‘Login” link is not working while running the code.

Please see attached image for code and testng.xml

Pankaj Default Asked on December 8, 2014 in Selenium WebDriver.

Please close your answer.

on December 9, 2014.
Add Comment
1 Answer(s)

Hi Pankaj,

There is no attachment. Please refer this page for TestNG Paramemeter: http://www.toolsqa.com/selenium-webdriver/testng-parameters-data-provider/

Test Case


import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
import org.testng.annotations.Parameters;
public class TestngParameters {
private static WebDriver driver;
@Test
@Parameters({ "sUsername", "sPassword" })
public void test(String sUsername, String sPassword) {
driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.store.demoqa.com");
driver.findElement(By.xpath(".//*[@id='account']/a")).click();
driver.findElement(By.id("log")).sendKeys(sUsername);
driver.findElement(By.id("pwd")).sendKeys(sPassword);
driver.findElement(By.id("login")).click();
driver.findElement(By.xpath(".//*[@id='account_logout']/a")).click();
driver.quit();
}
}

TestNG XML


<suite name="Suite">

<test name="ToolsQA">
<parameter name="sUsername" value="testuser_1"/>
<parameter name="sPassword" value="Test@123"/>
<classes>
<class name="automationFramework.TestngParameters" />
</classes>
</test>
</suite>

xLov3rDns Professor Answered on December 8, 2014.
Add Comment

Your Answer

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