Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package automation.warcart;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.support.ui.Select;
- public class Test {
- public static void main(String[] args) {
- WebDriver driver = Base.getDriver();
- // navigating website
- driver.get("https://www.walcart.com");
- //searching element by name
- WebElement searchBox = driver.findElement(By.id("search"));
- searchBox.sendKeys("Walton Keyboard WKS007WN");
- searchBox.submit();
- driver.findElement(By.linkText("Walton Keyboard WKS007WN")).click();
- driver.findElement(By.id("product-addtocart-button")).click();
- driver.findElement(By.xpath("//*[@id=\"minicart-content-wrapper\"]/div/div[2]/div[2]/div[1]/a")).click();
- driver.findElement(By.xpath("//*[@id=\"maincontent\"]/div/div[2]/div/div/div[2]/div[1]/ul/li/button")).click();
- WebElement mobile = driver.findElement(By.id("mobile"));
- mobile.sendKeys("01767552562");
- driver.findElement(By.xpath("//*[@id=\"tab-login\"]/div[3]/div[1]/button")).click();
- WebElement pass = driver.findElement(By.id("pass"));
- pass.sendKeys("rR01718910687");
- driver.findElement(By.xpath("/html/body/div[2]/main/div/div/div/div/div[2]/div/div/form[1]/fieldset/div/div[3]/div[2]")).click();
- WebElement number = driver.findElement(By.xpath("/html/body/div[1]/main/div/div[2]/div/div/div[2]/div[4]/ol/li[1]/div[2]/form/div/div[1]/div/input"));
- number.sendKeys("01767552562");
- WebElement address = driver.findElement(By.xpath("/html/body/div[1]/main/div/div[2]/div/div/div[2]/div[4]/ol/li[1]/div[2]/form/div/fieldset/div/div[1]/div/input"));
- address.sendKeys("Test Order");
- WebElement city = driver.findElement(By.xpath("/html/body/div[1]/main/div/div[2]/div/div/div[2]/div[4]/ol/li[1]/div[2]/form/div/div[7]/div/input"));
- city.sendKeys("Test Order");
- driver.findElement(By.xpath("/html/body/div[1]/main/div/div[2]/div/div/div[2]/div[4]/ol/li[2]/div/div[3]/form/div[3]/div/button")).click();
- //quit the window
- //driver.quit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement