Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. package com.qber.Pages;
  2. import org.openqa.selenium.By;
  3. import org.openqa.selenium.WebDriver;
  4. import org.openqa.selenium.WebElement;
  5. import org.openqa.selenium.support.ui.Select;
  6. public class LoginPage
  7. {
  8. WebDriver driver;
  9. WebElement element;
  10. By user=By.name("username");
  11. By pass=By.name("passsword");
  12. By button=By.className("button");
  13. By admin=By.linkText("Admin");
  14. By client=By.linkText("Clients");
  15. public LoginPage(WebDriver driver)
  16. {
  17. this.driver=driver;
  18.  
  19. }
  20. public void typeUser()
  21. {
  22. WebElement element=driver.findElement(By.name("username"));
  23. element.sendKeys("geosony");
  24.  
  25. }
  26. public void typePass()
  27. {
  28. element=driver.findElement(By.name("password"));
  29. element.sendKeys("1");
  30. }
  31. public void typeButton()
  32. {
  33. element.submit();
  34. }
  35. public void typeAdmin()
  36. {
  37. element=driver.findElement(By.linkText("Admin"));
  38. element.click();
  39. }
  40. public void typeClients()
  41. {
  42. element=driver.findElement(By.linkText("Clients"));
  43. element.click();
  44. element= driver.findElement(By.xpath("//*[@id='search-container']/a/i"));
  45. element.click();
  46. //check whether all fields are blank
  47. try
  48. {
  49. WebElement element1=driver.findElement(By.xpath("//*[@id='name']"));
  50. element1.submit();
  51. System.out.println("name is mandatory");
  52. }
  53. catch(Exception e)
  54. {
  55. System.out.println("incorrect"+e.getMessage());
  56. }
  57. }
  58. //check response for entering special character
  59. public void addclient()
  60. {
  61. try
  62. {
  63. WebElement element1=driver.findElement(By.id("name"));
  64. element1.sendKeys("Shaik");
  65. element1=driver.findElement(By.id("group_name"));
  66. element1.sendKeys("sk123");
  67. element1=driver.findElement(By.name("address"));
  68. element1.sendKeys("Uae");
  69. Select stat=new Select(driver.findElement(By.id("status")));
  70. stat.selectByVisibleText("active");
  71. element1.submit();
  72. System.out.println("Test passed");
  73.  
  74. }
  75. catch(Exception e)
  76. {
  77. System.out.println("incorrect"+e.getMessage());
  78. }
  79.  
  80.  
  81. }
  82. public void invalidClient()
  83. {
  84. try
  85. {
  86. WebElement element1=driver.findElement(By.id("name"));
  87. element1.sendKeys("@##");
  88. element1=driver.findElement(By.id("group_name"));
  89. element1.sendKeys("%$$%^$");
  90. element1=driver.findElement(By.name("address"));
  91. element1.sendKeys("#%$#%$");
  92. Select stat=new Select(driver.findElement(By.id("status")));
  93. stat.selectByVisibleText("inactive");
  94. element1.submit();
  95. System.out.println("Status is mandotory: Test passed");
  96. }
  97. catch(Exception e)
  98. {
  99. System.out.println("incorrect"+e.getMessage());
  100. }
  101. }
  102. }
  103.  
  104.  
  105. package com.qber.Testcases;
  106. import org.testng.annotations.Test;
  107. import org.openqa.selenium.firefox.FirefoxDriver;
  108.  
  109. import com.qber.Pages.LoginPage;
  110. @Test
  111. public class verifyLogin {
  112.  
  113. public void validLogin()
  114. {
  115. System.setProperty("webdriver.firefox.marionette","pathToGeckodriver");
  116. FirefoxDriver driver=new FirefoxDriver();
  117.  
  118.  
  119. driver.get("http://54.68.159.204/qmsadm");
  120. driver.manage().window().maximize();
  121.  
  122. LoginPage login=new LoginPage(driver);
  123. login.typePass();
  124. login.typeUser();
  125. login.typeButton();
  126. login.typeAdmin();
  127. login.typeClients();
  128. login.addclient();
  129. login.invalidClient();
  130. }
  131.  
  132.  
  133.  
  134.  
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement