0% found this document useful (0 votes)
38 views2 pages

Full Code

v

Uploaded by

surabhisharmamca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views2 pages

Full Code

v

Uploaded by

surabhisharmamca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

package selclassjan22;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.By.ByXPath;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.Select;

import io.github.bonigarcia.wdm.WebDriverManager;

public class today {

public static void main(String[] args) throws InterruptedException {


WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
driver.get("http://automationpractice.com/index.php");
//WebElement search = driver.findElement(By.id("search_query_top"));
WebElement search =
driver.findElement(By.xpath("//*[@id=\"search_query_top\"]"));
search.sendKeys("Shirt");
WebElement searchButton = driver.findElement(By.name("submit_search"));
searchButton.click();
WebElement image =
driver.findElement(By.xpath("//*[@id=\"center_column\"]/ul/li/div/div[1]/div/a[1]/
img"));
image.click();

driver.findElement(By.xpath(" //*[@id=\"quantity_wanted\"]")).clear();
driver.findElement(By.xpath("
//*[@id=\"quantity_wanted\"]")).sendKeys("5");
WebElement size = driver.findElement(By.xpath("//*[@id=\"group_1\"]"));
Select sizeupdate = new Select(size);
sizeupdate.selectByVisibleText("M");

driver.findElement(By.xpath(" //*[@id=\"color_14\"]")).click();
driver.findElement(By.xpath("
//*[@id=\"add_to_cart\"]/button/span")).click();

Thread.sleep(2000);
WebElement textdisplayed =
driver.findElement(By.xpath("//*[@id=\"layer_cart\"]/div[1]/div[1]/h2"));
String text= textdisplayed.getText();
System.out.println(text);

//Thread.sleep(2000);
WebElement proceedButton =
driver.findElement(By.xpath("//*[@id=\"layer_cart\"]/div[1]/div[2]/div[4]/a/
span"));
proceedButton.click();
WebElement element =
driver.findElement(By.xpath("//*[@id=\"header\"]/div[3]/div/div/div[3]/div/a\r\n"
+ ""));
Actions action = new Actions(driver);
action.moveToElement(element).perform();

List<WebElement> alltags = driver.findElements(By.tagName("a"));


System.out.println(alltags.size());
for(int i=0; i<alltags.size();i++)

{
System.out.println(alltags.get(i).getText());
}

//WebElement dropbox =
driver.findElement(By.xpath("//*[@id=\"selectProductSort\"]"));
//Select select = new Select(dropbox);
//select.selectByIndex(5);

You might also like