Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //step 1
- //opens up the log in page
- driver.get("https://qa3cc.absolute.com/default.aspx");
- //wait for 20 seconds for the web to load
- WebDriverWait wait = new WebDriverWait(driver,10);
- //check "DDS Login" exist
- wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"loginMainContent\"]/div[1]")));
- //check for username and password field exist
- wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"username\"]")));
- wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"password\"]")));
- //check if the current version is v6.0
- wait.until(ExpectedConditions.textToBe((By.xpath("//*[@id=\"bottom\"]/table/tbody/tr[1]/td[2]")),"v6.0"));
- //step 2
- WebElement loginButton = driver.findElement(By.xpath("//*[@id=\"LoginButton\"]"));
- //enter nothing and click login
- loginButton.click();
- //check specific error
- wait.until(ExpectedConditions.textToBe((By.xpath("//*[@id=\"LoginValidationSummary\"]")), "Invalid Username or password. Please try again."));
- //step 3
- WebElement username = driver.findElement(By.xpath("//*[@id=\"username\"]"));
- WebElement password = driver.findElement(By.xpath("//*[@id=\"password\"]"));
- username.sendKeys("demo1@absolute.com");
- loginButton.click();
- //check specific error
- wait.until(ExpectedConditions.textToBe((By.xpath("//*[@id=\"LoginValidationSummary\"]")), "Invalid Username or password. Please try again."));
- //step 4
- username = driver.findElement(By.xpath("//*[@id=\"username\"]"));
- username.clear();
- username.sendKeys("dummy@absolute.com");
- //get password and set to a valid password
- password = driver.findElement(By.xpath("//*[@id=\"password\"]"));
- password.sendKeys("Password1234");
- loginButton.click();
- //check specific error
- wait.until(ExpectedConditions.textToBe((By.xpath("//*[@id=\"LoginValidationSummary\"]")), "Invalid Username or password. Please try again."));
- //step 5
- username = driver.findElement(By.xpath("//*[@id=\"username\"]"));
- password = driver.findElement(By.xpath("//*[@id=\"password\"]"));
- username.clear();
- username.sendKeys("demo1@absolute.com");
- password.sendKeys("Password12345");
- loginButton = driver.findElement(By.xpath("//*[@id=\"LoginButton\"]"));
- loginButton.click();
- //check specific error
- wait.until(ExpectedConditions.textToBe((By.xpath("//*[@id=\"LoginValidationSummary\"]")), "Invalid Username or password. Please try again."));
- //step 6
- username = driver.findElement(By.xpath("//*[@id=\"username\"]"));
- password = driver.findElement(By.xpath("//*[@id=\"password\"]"));
- username.clear();
- username.sendKeys("demo1@absolute.com");
- password.sendKeys("Password1234");
- loginButton = driver.findElement(By.xpath("//*[@id=\"LoginButton\"]"));
- loginButton.click();
- //step 7
- //operate to asset report page
- wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"ctl00_AccordionMenu2_id6_depth1\"]/div[3]/span")));
- WebElement Reports = driver.findElement(By.xpath("//*[@id=\"ctl00_AccordionMenu2_id6_depth1\"]/div[3]/span"));
- Reports.click();
- wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"subMenuContentDiv\"]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/a[1]")));
- WebElement assetReport = driver.findElement(By.xpath("//*[@id=\"subMenuContentDiv\"]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/a[1]"));
- assetReport.click();
- //check if Asset Report Page is loaded
- wait.until(ExpectedConditions.textToBe((By.xpath("//*[@id=\"bodyContentDiv\"]/div[1]/div[1]")), "Asset Report"));
- //check asset list is opened
- wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_ddlValues\"]")));
- //step 8
- //setting up conditions
- Select fieldDropdown = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_ddlValues\"]")));
- fieldDropdown.selectByVisibleText("Identifier");
- WebElement identifierKey = driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_tbxValue\"]"));
- identifierKey.sendKeys("R0026");
- Select agentVersionDropdown = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl04_usrItem_computraceVersion_ddlAgentVersion\"]")));
- agentVersionDropdown.selectByVisibleText("932");
- //show result
- WebElement showResult = driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_usrFooter_btnSubmit\"]"));
- showResult.click();
- //verify if the hyperlinks is clickable
- wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_resultsContent_gvAssets_gvResults\"]/tbody/tr[2]/td[3]/a")));
- //step 9
- //setting up new conditions
- fieldDropdown = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_ddlValues\"]")));
- fieldDropdown.selectByVisibleText("Device Name");
- identifierKey = driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl02_usrItem_usrFields_tbxValue\"]"));
- identifierKey.clear();
- identifierKey.sendKeys("QA");
- agentVersionDropdown = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_ctl04_usrItem_computraceVersion_ddlAgentVersion\"]")));
- agentVersionDropdown.selectByVisibleText("Any Version");
- //show result
- showResult = driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_cpSearch_searchCriteriaContent_usrDataboundSearchCriteria_usrFooter_btnSubmit\"]"));
- showResult.click();
- //verify if the hyperlinks is clickable
- Select rowPerPage = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_resultsContent_gvAssets_ddlResultsPerPageTop\"]")));
- //select 1000 rows per page
- rowPerPage.selectByVisibleText("1000");
- wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_resultsContent_gvAssets_gvResults\"]/tbody/tr[2]/td[3]/a")));
- int rowCount=driver.findElements(By.xpath("//*[@id=\"ctl00_ctl00_bodyContent_resultsContent_gvAssets_gvResults\"]/tbody/tr")).size();
- System.out.println(rowCount);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement