Программисты JAVA общаются здесь
Anonymous
Вход в Gmail с использованием веб-драйвера Selenium в Java
Сообщение
Anonymous » 21 май 2024, 05:45
Код: Выделить всё
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class NewGmail {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
String url = "https://accounts.google.com/signin";
driver.get(url);
driver.findElement(By.id("identifierId")).sendKeys("cp8805");
//driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
WebDriverWait wait=new WebDriverWait(driver, 20);
driver.findElement(By.xpath("//span[@class='RveJvd snByac']")).click();
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
driver.findElement(By.xpath("//input[@class='whsOnd zHQkBf']")).sendKeys("xxxxxx");
driver.findElement(By.xpath("//span[@class='RveJvd snByac']")).click();
}
}
после идентификатора почты мой пароль также записывается в поле идентификатора, и сервер перенаправляет на следующую страницу пароля. я хочу спросить, что мне сделать, чтобы мой пароль вводился только на странице паролей.
Подробнее здесь:
https://stackoverflow.com/questions/444 ... er-in-java
1716259526
Anonymous
[code]import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public class NewGmail { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.manage().window().maximize(); String url = "https://accounts.google.com/signin"; driver.get(url); driver.findElement(By.id("identifierId")).sendKeys("cp8805"); //driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); WebDriverWait wait=new WebDriverWait(driver, 20); driver.findElement(By.xpath("//span[@class='RveJvd snByac']")).click(); driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS); driver.findElement(By.xpath("//input[@class='whsOnd zHQkBf']")).sendKeys("xxxxxx"); driver.findElement(By.xpath("//span[@class='RveJvd snByac']")).click(); } } [/code] после идентификатора почты мой пароль также записывается в поле идентификатора, и сервер перенаправляет на следующую страницу пароля. я хочу спросить, что мне сделать, чтобы мой пароль вводился только на странице паролей. Подробнее здесь: [url]https://stackoverflow.com/questions/44455269/gmail-login-using-selenium-webdriver-in-java[/url]