Advertisement
Guest User

Untitled

a guest
Apr 28th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.57 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.  
  62. //step 7
  63.  
  64. //operate to asset report page
  65. wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"ctl00_AccordionMenu2_id6_depth1\"]/div[3]/span")));
  66. WebElement Reports = driver.findElement(By.xpath("//*[@id=\"ctl00_AccordionMenu2_id6_depth1\"]/div[3]/span"));
  67. Reports.click();
  68.  
  69. wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"subMenuContentDiv\"]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/a[1]")));
  70. WebElement assetReport = driver.findElement(By.xpath("//*[@id=\"subMenuContentDiv\"]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/a[1]"));
  71. assetReport.click();
  72.  
  73.  
  74. //check if Asset Report Page is loaded
  75. wait.until(ExpectedConditions.textToBe((By.xpath("//*[@id=\"bodyContentDiv\"]/div[1]/div[1]")), "Asset Report"));
  76. //check asset list is opened
  77. wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_ddlValues\"]")));
  78.  
  79. //step 8
  80.  
  81. //setting up conditions
  82. Select fieldDropdown = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_ddlValues\"]")));
  83. fieldDropdown.selectByVisibleText("Identifier");
  84. WebElement identifierKey = driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_tbxValue\"]"));
  85. identifierKey.sendKeys("R0026");
  86. Select agentVersionDropdown = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl04_usrItem_computraceVersion_ddlAgentVersion\"]")));
  87. agentVersionDropdown.selectByVisibleText("932");
  88. //show result
  89. WebElement showResult = driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_usrFooter_btnSubmit\"]"));
  90. showResult.click();
  91. //verify if the hyperlinks is clickable
  92. wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_resultsContent_gvAssets_gvResults\"]/tbody/tr[2]/td[3]/a")));
  93.  
  94. //step 9
  95.  
  96. //setting up new conditions
  97. fieldDropdown = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_ddlValues\"]")));
  98. fieldDropdown.selectByVisibleText("Device Name");
  99. identifierKey = driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_tbxValue\"]"));
  100. identifierKey.clear();
  101. identifierKey.sendKeys("QA");
  102. agentVersionDropdown = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl04_usrItem_computraceVersion_ddlAgentVersion\"]")));
  103. agentVersionDropdown.selectByVisibleText("Any Version");
  104. //show result
  105. showResult = driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_usrFooter_btnSubmit\"]"));
  106. showResult.click();
  107. //verify if the hyperlinks is clickable
  108. Select rowPerPage = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_resultsContent_gvAssets_ddlResultsPerPageTop\"]")));
  109. //select 1000 rows per page
  110. rowPerPage.selectByVisibleText("1000");
  111.  
  112. wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_resultsContent_gvAssets_gvResults\"]/tbody/tr[2]/td[3]/a")));
  113. int rowCount=driver.findElements(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_resultsContent_gvAssets_gvResults\"]/tbody/tr")).size();
  114. System.out.println(rowCount);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement