Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. Given I open the browser and access this URL
  2. When I enter the "<Username>" and "<Password>"
  3. Then I am able to login
  4.  
  5. WebDriver driver = null;
  6. String url;
  7.  
  8.  
  9. @Given("^I open the browser and access this URL$")
  10. public void navigateToUrl() throws Throwable{
  11.  
  12. System.setProperty("webdriver.chrome.driver", "");
  13. driver = new ChromeDriver();
  14. url = DataTable.getDataTableValue(0, 2, 2);
  15. driver.get(url);
  16. driver.manage().window().maximize();
  17. }
  18.  
  19. @When("^I enter the "([^"]*)" and "([^"]*)"$")
  20. public void enterCredentials(String userName, String password ) throws Throwable {
  21.  
  22. userName = DataTable.getDataTableValue(0, 1, 1);
  23. password = DataTable.getDataTableValue(0, 1, 2);
  24.  
  25. driver.findElement(By.id("username")).sendKeys(userName);
  26. driver.findElement(By.id("password")).sendKeys(password);
  27. }
  28.  
  29. @Then("^I am able to login$")
  30. public void clickLoginButton() throws Throwable {
  31. driver.findElement(By.id("Login")).click();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement