Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. Hi All,
  2.  
  3. 1) This is my feature file
  4.  
  5. Scenario Outline: Login to the application
  6. Given The application is launched
  7. When I enter the "<username>" and "<password>"
  8. And click on the login button
  9. Then I am logged into the application
  10.  
  11. Examples:
  12. | username | password |
  13. | admin | admin |
  14.  
  15. @Party
  16. Scenario Outline: Add new person or place
  17. Given The application is launched is with "<username>" and "<password>"
  18. When I click on Party button
  19. And I click on Add new Person Or Place
  20. And I select organization
  21. And I enter the partyname "<organizationName>" and "<correspondenceName>"
  22. And I enter the address "<Address>" and "<City>" and "<zipcode>"
  23. And I click on Done
  24. Then Verify the "<organizationName>" created
  25.  
  26. Examples:
  27. | username | password | organizationName | correspondenceName | Address | City | zipcode |
  28. | admin | admin | orginsured | orginsured | 100 Main Rd | Bolivar | 65613 |
  29.  
  30.  
  31. Then
  32.  
  33. 2) I have created a base class,
  34.  
  35. public class BaseStepDefinition {
  36.  
  37. WebDriver driver = new FirefoxDriver();
  38. }
  39.  
  40.  
  41. 3) I have 2 step definition class extending BaseStepDefinition class
  42.  
  43. public class LoginFunctionality extends BaseStepDefinition {
  44. @Before
  45. public void launchbrowser() {
  46. WebDriver driver = new FirefoxDriver();
  47. String url = "SomeURL";
  48. driver.get(url);
  49.  
  50. }
  51.  
  52.  
  53. @After public void closebrowser() {
  54. driver.findElement(By.id("id_LogOut")).click(); driver.close();
  55. }
  56.  
  57.  
  58. @Given("^The application is launched$")
  59. public void the_application_is_launched() throws Throwable {
  60. // Write code here that turns the phrase above into concrete actions
  61. // driver.get(url);
  62. String expectedtitle = "title";
  63. String actualtitle = driver.getTitle();
  64. Assert.assertEquals(actualtitle, expectedtitle);
  65.  
  66. }
  67.  
  68. @When("^I enter the "([^"]*)" and "([^"]*)"$")
  69. public void i_enter_the_and(String arg1, String arg2) throws Throwable {
  70. // Write code here that turns the phrase above into concrete actions
  71. WebElement username = driver.findElement(By.id("username"));
  72. username.sendKeys(arg1);
  73. WebElement password = driver.findElement(By.id("password"));
  74. password.sendKeys(arg2);
  75. }
  76.  
  77. @Given("^The application is launched is with "([^"]*)" and "([^"]*)"$")
  78. public void login(String arg1, String arg2) throws Throwable {
  79. WebElement username = driver.findElement(By.id("username"));
  80. username.sendKeys(arg1);
  81. WebElement password = driver.findElement(By.id("password"));
  82. password.sendKeys(arg2);
  83. WebElement clicklogin = driver.findElement(By.xpath("//span[text()='Login']"));
  84. clicklogin.click();
  85. }
  86.  
  87. @When("^I click on Party button$")
  88. public void i_click_on_Party_button() throws Throwable {
  89. driver.findElement(By.id("Party")).click();
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement