Selenium Commands:-
1. Command to Open URL:
driver.get("https://google.com");
2. Command to get current page URL:
driver.getCurrentUrl();
This commands is use to get the current page Url. If I write:
String curr_url=driver.getCurrentUrl();
Then in curr_url string store current page URL.
3. Command to get pagesource:
String pagesrc=driver.getPageSource();
In string pagesrc, pagesource of the current accessing page will be store.
4. Command to Click on the WebElement:
driver.findElement(By.id("PutHerelocatorOfWebElement")).click();
5. Command to get text from text field or any other webelements like dropdown etc.
String txt=driver.findElement(By.id("id of text field")).getText();
String dropdown=driver.findElement(By.tagName("select")).getText();
6. Command to enter text in text field:
driver.findElement(By.id("id of text field")).sendKeys("Hello World");
7. Command to get page title:
String pagetitle=driver.getTitle();
8. Command to navigate to URL:
driver.navigate().to("http://google.com"); // Navigate to given url
driver.navigate().back(); // Navigate to page in back direction
driver.navigate().forward(); // Navigate to page in forward direction
9. Command to apply implicit wait:
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
This command is wait till 10 seconds, if web element is not found on the page.
10. Command to apply Explicit wait:
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeSelected(By.xpath("//div[@id='timeLeft']")));
Selenium Commands Part-2
1. Command to Open URL:
driver.get("https://google.com");
2. Command to get current page URL:
driver.getCurrentUrl();
This commands is use to get the current page Url. If I write:
String curr_url=driver.getCurrentUrl();
Then in curr_url string store current page URL.
3. Command to get pagesource:
String pagesrc=driver.getPageSource();
In string pagesrc, pagesource of the current accessing page will be store.
4. Command to Click on the WebElement:
driver.findElement(By.id("PutHerelocatorOfWebElement")).click();
5. Command to get text from text field or any other webelements like dropdown etc.
String txt=driver.findElement(By.id("id of text field")).getText();
String dropdown=driver.findElement(By.tagName("select")).getText();
6. Command to enter text in text field:
driver.findElement(By.id("id of text field")).sendKeys("Hello World");
7. Command to get page title:
String pagetitle=driver.getTitle();
8. Command to navigate to URL:
driver.navigate().to("http://google.com"); // Navigate to given url
driver.navigate().back(); // Navigate to page in back direction
driver.navigate().forward(); // Navigate to page in forward direction
9. Command to apply implicit wait:
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
This command is wait till 10 seconds, if web element is not found on the page.
10. Command to apply Explicit wait:
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeSelected(By.xpath("//div[@id='timeLeft']")));
Selenium Commands Part-2
No comments:
Post a Comment