-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment165.java
More file actions
33 lines (24 loc) · 1.06 KB
/
Assignment165.java
File metadata and controls
33 lines (24 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package BasicsSelenium;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
//WAP to search anything in https://pharmeasy.in/ & select the 3rd option ?
public class Assignment165 {
public static void main(String[] args) throws InterruptedException {
ChromeDriver driver = new ChromeDriver();
driver.get("https://pharmeasy.in/");
driver.manage().window().maximize();
WebElement searchbar = driver.findElement(By.xpath(
"(//span[@class='c-kkmdlQ c-kkmdlQ-gatHuX-structure-captionRegular c-kkmdlQ-dYJjti-weight-regular c-kkmdlQ-euWHqW-structure-inputValue c-kkmdlQ-iftOpAg-css'])[2]"));
searchbar.click();
driver.findElement(By.xpath("//input[@type='text']")).sendKeys("moov");
Thread.sleep(3000);
List<WebElement> a1 = driver.findElements(By.xpath(
"(//div[@class='c-PJLV c-bXbWpx c-bXbWpx-bZJlhX-direction-column c-bXbWpx-iieFQlv-css']/div)[2]/a"));
Thread.sleep(3000);
int count = a1.size();
System.out.println(count);
a1.get(count - 8).click();
}
}