Intellij Selenium Code For Automation
Intellij Selenium Code For Automation
Intellij Selenium Code For Automation
Test
System.setProperty("webdriver.chrome.driver","D:\\kit\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
String keyword = "primul test";
driver.get("https://www.seleniumeasy.com/test/basic-first-form-demo.html");
import net.bytebuddy.utility.RandomString;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.Assert;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
System.setProperty("webdriver.chrome.driver", "D:\\kit\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
String keyword = "primul test";
driver.get("https://www.seleniumeasy.com/test/basic-first-form-demo.html");
System.setProperty("webdriver.chrome.driver", "D:\\kit\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
int nr1 = 4;
int nr2 = 3;
int sum = nr1 + nr2;
driver.get("https://www.seleniumeasy.com/test/basic-first-form-demo.html");
@org.testng.annotations.Test
public void alTreileaTest() {
System.setProperty("webdriver.chrome.driver",
"D:\\kit\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.seleniumeasy.com/test/basic-select-dropdown-
demo.html");
WebElement dropdownButton = driver.findElement(By.id("select-demo"));
Select selector = new Select(dropdownButton);
selector.selectByValue("Monday");
int index;
for(index=0; index <=7; index++);
selector.selectByIndex(index);
WebElement result =
driver.findElement(By.xpath("//*[@id=\"easycont\"]/div/div[2]/div[1]/div[2]/p[2]"))
;
switch(index){
case 1:
Assert.assertEquals(result.getText(), "Day selected :- Sunday") ;
}
@org.testng.annotations.Test
System.setProperty("webdriver.chrome.driver", "D:\\kit\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.decathlon.ro/");
WebElement decathlonLogo = driver.findElement(By.id("dkt-logo"));
Assert.assertTrue(decathlonLogo.isDisplayed());
searchBar.click();
searchBar.sendKeys(keyword);
searchBar.sendKeys(Keys.RETURN);
WebElement searchResult =
driver.findElement(By.xpath("//*[@id=\"middle\"]/div[2]/div[1]/h1"));
Assert.assertEquals(searchResult.getText().toLowerCase(),keyword.toLowerCase());
}
}