Pdfs Design30
Pdfs Design30
Position value of 6 is 4.
Eg: (//input[@type=’radio’])[4]
Assignment: open browser enter google url type phone
and fetch the 4th value in console.
package Locators;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
driver.findElement(By.xpath("//textarea[@name='q'
]")).sendKeys("phone");
//Thread.sleep(5000);
List<WebElement> value =
driver.findElements(By.xpath("//li[@data-view-
type='1'][4]"));
for(WebElement b:value) {
System.out.println(b.getText());
Thread.sleep(5000);
driver.close();
Synchronization:
Synchronization: It is a process of matching the
selenium speed with Application speed.
Types of Synchronization:
1.Implicitly wait
2. Explicitly wait
3.Thread.sleep
1.Implicitly wait :
It is a selenium wait which is used to match the
selenium speed with application speed.
Syntax:
driver.manage().timeouts().implicitlyWait(Duration,
TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(20,
TimeUnit.SECONDS);