Advertisement
rahat62

Automation Testing

Oct 7th, 2022 (edited)
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.09 KB | None | 0 0
  1. package automation.warcart;
  2.  
  3. import org.openqa.selenium.By;
  4. import org.openqa.selenium.WebDriver;
  5. import org.openqa.selenium.WebElement;
  6. import org.openqa.selenium.support.ui.Select;
  7.  
  8. public class Test {
  9.  
  10.     public static void main(String[] args) {
  11.        
  12.         WebDriver driver = Base.getDriver();
  13.        
  14.                
  15.         // navigating website
  16.         driver.get("https://www.walcart.com");
  17.  
  18.        
  19.         //searching element by name
  20.         WebElement searchBox = driver.findElement(By.id("search"));
  21.         searchBox.sendKeys("Walton Keyboard WKS007WN");
  22.         searchBox.submit();
  23.        
  24.         driver.findElement(By.linkText("Walton Keyboard WKS007WN")).click();
  25.        
  26.         driver.findElement(By.id("product-addtocart-button")).click();
  27.        
  28.         driver.findElement(By.xpath("//*[@id=\"minicart-content-wrapper\"]/div/div[2]/div[2]/div[1]/a")).click();
  29.         driver.findElement(By.xpath("//*[@id=\"maincontent\"]/div/div[2]/div/div/div[2]/div[1]/ul/li/button")).click();
  30.        
  31.        
  32.        
  33.         WebElement mobile = driver.findElement(By.id("mobile"));
  34.         mobile.sendKeys("01767552562");
  35.         driver.findElement(By.xpath("//*[@id=\"tab-login\"]/div[3]/div[1]/button")).click();
  36.        
  37.         WebElement pass = driver.findElement(By.id("pass"));
  38.         pass.sendKeys("rR01718910687");
  39.         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();
  40.    
  41.         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"));
  42.         number.sendKeys("01767552562");
  43.        
  44.         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"));
  45.         address.sendKeys("Test Order");
  46.        
  47.         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"));
  48.         city.sendKeys("Test Order");
  49.        
  50.         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();
  51.        
  52.         //quit the window
  53.         //driver.quit();
  54.  
  55.     }
  56.  
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement