-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutomate_Form
36 lines (32 loc) · 1.66 KB
/
Automate_Form
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
34
35
36
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Automate_Form {
public static void main(String args[])
{
System.setProperty("web driver.chrome.driver", "Actual Path of the Chrome Driver"); //Enter the actual path of the Chrome driver i.e. where is it being stored in the local device.
//Now there is no need to state the above-mentioned line since the 'Selenium Manager' now directly handles the Chrome driver(without actually downloading it to the local device)
WebDriver driver = new ChromeDriver();
driver.get("https://www.techlistic.com/p/selenium-practice-form.html");
driver.findElement(By.name("firstname")).click();
driver.findElement(By.name("firstname")).sendKeys("Test");
driver.findElement(By.name("lastname")).click();
driver.findElement(By.name("lastname")).sendKeys("Testone");
driver.findElement(By.id("sex-1")).click();
driver.findElement(By.id("exp-3")).click();
driver.findElement(By.id("datepicker")).click();
driver.findElement(By.id("datepicker")).sendKeys("31-10-02");
driver.findElement(By.id("profession-0")).click();
driver.findElement(By.id("tool-2")).click();
// Select Continent
driver.findElement(By.id("continents")).click();
WebElement dropdown = driver.findElement(By.id("continents"));
dropdown.findElement(By.xpath("//option[. = 'Europe']")).click();
// Select Command
WebElement dropdown1 = driver.findElement(By.id("selenium_commands"));
dropdown1.findElement(By.xpath("//option[. = 'Browser Commands']")).click();
driver.findElement(By.id("submit")).click();
driver.close();
}
}