-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyFirstTest.java
73 lines (36 loc) · 1.78 KB
/
MyFirstTest.java
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.company.tests;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class MyFirstTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setHeadless(false);
System.setProperty("webdriver.chrome.driver","C:\\Users\\Beep Informatica\\eclipse-workspace\\demostracion\\src\\drivers\\chromedriver.exe");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://github.com/login");
//para maximizar
driver.manage().window().maximize();
//titulo
System.out.println("El título de la página es " + driver.getTitle());
// cerrar
// driver.close();
//encontrar elementos de la página e interactuar con ellos
//usando id y class
//driver.get("https://github.com/login");
//driver.findElement(By.id("login_field")).sendKeys("usuario");
//driver.findElement(By.id("password")).sendKeys("contraseña");
//driver.findElement(By.className("js-sign-in-button")).click();
//usando xpath
//tagname[@attribute='value']/abc/xyz
driver.findElement(By.xpath("//input[@name='login']")).sendKeys("usuario");
driver.findElement(By.xpath("//input[@name='password']")).sendKeys("contraseña");
driver.findElement(By.xpath("//input[@name='commit']")).click();
//usando CSSSelector
//driver.findElement(By.cssSelector("input#login_field")).sendKeys("usuario");
//driver.findElement(By.cssSelector("input#password")).sendKeys("contraseña");
//driver.findElement(By.cssSelector("input.js-sign-in-button")).click();
}
}