Advertisement
Guest User

Untitled

a guest
Apr 28th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.95 KB | None | 0 0
  1. //step 1
  2. //opens up the log in page
  3. driver.get("https://qa3cc.absolute.com/default.aspx");
  4. //wait for 20 seconds for the web to load
  5. WebDriverWait wait = new WebDriverWait(driver,10);
  6.  
  7. //check "DDS Login" exist
  8. wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"loginMainContent\"]/div[1]")));
  9. //check for username and password field exist
  10. wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"username\"]")));
  11. wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"password\"]")));
  12. //check if the current version is v6.0
  13. wait.until(ExpectedConditions.textToBe((By.xpath("//*[@id=\"bottom\"]/table/tbody/tr[1]/td[2]")),"v6.0"));
  14.  
  15. //step 2
  16. WebElement loginButton = driver.findElement(By.xpath("//*[@id=\"LoginButton\"]"));
  17. //enter nothing and click login
  18. loginButton.click();
  19. //check specific error
  20. wait.until(ExpectedConditions.textToBe((By.xpath("//*[@id=\"LoginValidationSummary\"]")), "Invalid Username or password. Please try again."));
  21.  
  22. //step 3
  23. WebElement username = driver.findElement(By.xpath("//*[@id=\"username\"]"));
  24. WebElement password = driver.findElement(By.xpath("//*[@id=\"password\"]"));
  25. username.sendKeys("demo1@absolute.com");
  26. loginButton.click();
  27. //check specific error
  28. wait.until(ExpectedConditions.textToBe((By.xpath("//*[@id=\"LoginValidationSummary\"]")), "Invalid Username or password. Please try again."));
  29.  
  30. //step 4
  31. username = driver.findElement(By.xpath("//*[@id=\"username\"]"));
  32. username.clear();
  33. username.sendKeys("dummy@absolute.com");
  34. //get password and set to a valid password
  35. password = driver.findElement(By.xpath("//*[@id=\"password\"]"));
  36. password.sendKeys("Password1234");
  37.  
  38. loginButton.click();
  39. //check specific error
  40. wait.until(ExpectedConditions.textToBe((By.xpath("//*[@id=\"LoginValidationSummary\"]")), "Invalid Username or password. Please try again."));
  41.  
  42. //step 5
  43. username = driver.findElement(By.xpath("//*[@id=\"username\"]"));
  44. password = driver.findElement(By.xpath("//*[@id=\"password\"]"));
  45. username.clear();
  46. username.sendKeys("demo1@absolute.com");
  47. password.sendKeys("Password12345");
  48. loginButton = driver.findElement(By.xpath("//*[@id=\"LoginButton\"]"));
  49. loginButton.click();
  50. //check specific error
  51. wait.until(ExpectedConditions.textToBe((By.xpath("//*[@id=\"LoginValidationSummary\"]")), "Invalid Username or password. Please try again."));
  52.  
  53. //step 6
  54. username = driver.findElement(By.xpath("//*[@id=\"username\"]"));
  55. password = driver.findElement(By.xpath("//*[@id=\"password\"]"));
  56. username.clear();
  57. username.sendKeys("demo1@absolute.com");
  58. password.sendKeys("Password1234");
  59. loginButton = driver.findElement(By.xpath("//*[@id=\"LoginButton\"]"));
  60. loginButton.click();
  61. wait.until(ExpectedConditions.urlToBe("https://qa3cc.absolute.com/Pages/Home.aspx"));
  62.  
  63. //step 7
  64.  
  65. //operate to asset report page
  66. wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"ctl00_AccordionMenu2_id6_depth1\"]/div[3]/span")));
  67. WebElement Reports = driver.findElement(By.xpath("//*[@id=\"ctl00_AccordionMenu2_id6_depth1\"]/div[3]/span"));
  68. Reports.click();
  69.  
  70. wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"subMenuContentDiv\"]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/a[1]")));
  71. WebElement assetReport = driver.findElement(By.xpath("//*[@id=\"subMenuContentDiv\"]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/a[1]"));
  72. assetReport.click();
  73.  
  74.  
  75. //check if Asset Report Page is loaded
  76. wait.until(ExpectedConditions.textToBe((By.xpath("//*[@id=\"bodyContentDiv\"]/div[1]/div[1]")), "Asset Report"));
  77. //check asset list is opened
  78. wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_ddlValues\"]")));
  79.  
  80. //step 8
  81.  
  82. //setting up conditions
  83. Select fieldDropdown = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_ddlValues\"]")));
  84. fieldDropdown.selectByVisibleText("Identifier");
  85. WebElement identifierKey = driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_tbxValue\"]"));
  86. identifierKey.sendKeys("R0026");
  87. Select agentVersionDropdown = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl04_usrItem_computraceVersion_ddlAgentVersion\"]")));
  88. agentVersionDropdown.selectByVisibleText("932");
  89. //show result
  90. WebElement showResult = driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_usrFooter_btnSubmit\"]"));
  91. showResult.click();
  92. //verify if the hyperlinks is clickable
  93. wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_resultsContent_gvAssets_gvResults\"]/tbody/tr[2]/td[3]/a")));
  94.  
  95. //step 9
  96.  
  97. //setting up new conditions
  98. fieldDropdown = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_ddlValues\"]")));
  99. fieldDropdown.selectByVisibleText("Device Name");
  100. identifierKey = driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_tbxValue\"]"));
  101. identifierKey.clear();
  102. identifierKey.sendKeys("QA");
  103. agentVersionDropdown = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl04_usrItem_computraceVersion_ddlAgentVersion\"]")));
  104. agentVersionDropdown.selectByVisibleText("Any Version");
  105. //show result
  106. showResult = driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_usrFooter_btnSubmit\"]"));
  107. showResult.click();
  108. //verify if the hyperlinks is clickable
  109. Select rowPerPage = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_resultsContent_gvAssets_ddlResultsPerPageTop\"]")));
  110. //select 1000 rows per page
  111. rowPerPage.selectByVisibleText("1000");
  112.  
  113. wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_resultsContent_gvAssets_gvResults\"]/tbody/tr[2]/td[3]/a")));
  114. int rowCount=driver.findElements(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_resultsContent_gvAssets_gvResults\"]/tbody/tr")).size();
  115. System.out.println("There are " + rowCount + " rows in the table");
  116.  
  117. //step 10
  118.  
  119. WebElement logout = driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_LogoutLinkButton\"]"));
  120. logout.click();
  121. wait.until(ExpectedConditions.urlToBe("https://qa3cc.absolute.com/Default.aspx/?ReturnUrl=%2FPages%2FReports%2FAssetReport.aspx"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement