Advertisement
Guest User

Untitled

a guest
Aug 1st, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. public class Login {
  2. public static WebDriver driver;
  3. String username = "username";
  4. String password = "password";
  5. String baseurl = "http://mybusiness.com/login.aspx";
  6.  
  7.  
  8. public class Details {
  9. @Test(priority = 0)
  10. public void loginpage() {
  11. //WebDriver driver = new FirefoxDriver();
  12. System.setProperty("webdriver.chrome.driver","D:\From H\Selenium Package\ChromeDriver\chromedriver_win32\chromedriver.exe");
  13.  
  14. DesiredCapabilities capabilities = DesiredCapabilities.chrome();
  15. capabilities.setCapability("chrome.switches", Arrays.asList("--incognito"));
  16. ChromeOptions options = new ChromeOptions();
  17. options.addArguments("--test-type");
  18. options.addArguments("--disable-extensions");
  19. capabilities.setCapability("chrome.binary","D:\From H\Selenium Package\ChromeDriver\chromedriver_win32\chromedriver.exe");
  20. capabilities.setCapability(ChromeOptions.CAPABILITY, options);
  21.  
  22.  
  23. driver = new ChromeDriver(capabilities);
  24. driver.manage().deleteAllCookies();
  25. driver.manage().window().maximize();
  26. driver.get(baseurl);
  27.  
  28. try {
  29. Thread.sleep(10000); // 1000 milliseconds is one second.
  30. } catch (InterruptedException ex) {
  31. Thread.currentThread().interrupt();
  32. }
  33. WebElement username = driver.findElement(By.id("UserName"));
  34. username.sendKeys(username);
  35. try {
  36. Thread.sleep(10000); // 1000 milliseconds is one second.
  37. } catch (InterruptedException ex) {
  38. Thread.currentThread().interrupt();
  39. }
  40. WebElement password = driver.findElement(By.id("Password"));
  41. password.sendKeys(password);
  42. try {
  43. Thread.sleep(10000);
  44. } catch (InterruptedException ex) {
  45. Thread.currentThread().interrupt();
  46. }
  47. WebElement button = driver.findElement(By.id("ButtonClick"));
  48. button.click();
  49. try {
  50. Thread.sleep(10000);
  51. } catch (InterruptedException ex) {
  52. Thread.currentThread().interrupt();
  53. }
  54. }
  55.  
  56. // Selecting a date from date picker
  57. @Test(priority = 1)
  58. public void RecordSearch() {
  59. WebElement calendar = driver.findElement(By.id("CalendarId"));
  60. calendar.click();
  61. try {
  62. Thread.sleep(5000); // 1000 milliseconds is one second.
  63. } catch (InterruptedException ex) {
  64. Thread.currentThread().interrupt();
  65. }
  66.  
  67. WebElement month = driver.findElement(By.xpath("XPath"));
  68. month.click();
  69. try {
  70. Thread.sleep(5000); // 1000 milliseconds is one second.
  71. } catch (InterruptedException ex) {
  72. Thread.currentThread().interrupt();
  73. }
  74.  
  75. WebElement day = driver.findElement(By.xpath("XPath"));
  76. day.click();
  77. try {
  78. Thread.sleep(5000); // 1000 milliseconds is one second.
  79. } catch (InterruptedException ex) {
  80. Thread.currentThread().interrupt();
  81. }
  82.  
  83. WebElement submit = driver.findElement(By.id("Submit"));
  84. submit.click();
  85. try {
  86. Thread.sleep(10000); // 1000 milliseconds is one second.
  87. } catch (InterruptedException ex) {
  88. Thread.currentThread().interrupt();
  89. }
  90.  
  91. }
  92.  
  93. driver.close();
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement