- Creating New Instance
- Command To Open URL In Browser
- Clicking on any element or button of webpage
- Store text of targeted element in variable
- Typing text in text box or text area.
- Applying Implicit wait in webdriver
- Applying Explicit wait in webdriver with WebDriver canned conditions.
- Get page title in selenium webdriver
- Get Current Page URL In Selenium WebDriver
- Get domain name using java script executor
- Generate alert using webdriver's java script executor interface
- Selecting or Deselecting value from drop down in selenium webdriver. Select By Visible Text
WebDriver driver = new FirefoxDriver()
The above command is used to open a new instance of Firefox driverdriver.get("http://only-testing-blog.blogspot.com/2013/11/new-test.html");
This syntax will open specified URL of software web application in web browser.
driver.findElement(By.id("submitButton")).click();
Above given syntax will click on targeted element in webdriver.
String dropdown = driver.findElement(By.tagName("select")).getText();
This syntax will retrieve text from targeted element of software web application page and will store it in variable = dropdown.
driver.findElement(By.name("fname")).sendKeys("My First Name");
Above syntax will type specified text in targeted element. VIEW PRACTICAL EXAMPLE OF SendKeys
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
This syntax will force webdriver to wait for 15 second if element not found on page of software web application.
WebDriverWait wait = new WebDriverWait(driver, 15); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath("//div[@id='timeLeft']"), "Time left: 7 seconds"));
Above 2 syntax will wait for till 15 seconds for expected text "Time left: 7 seconds" to be appear on targeted element.
Comments
Post a Comment