Java 我正在尝试使用selenium在自动化测试下执行我的maven项目
要在电子邮件地址和密码字段中发送凭据,您可以使用以下选项:Java 我正在尝试使用selenium在自动化测试下执行我的maven项目,java,selenium,selenium-webdriver,webdriver,webdriverwait,Java,Selenium,Selenium Webdriver,Webdriver,Webdriverwait,要在电子邮件地址和密码字段中发送凭据,您可以使用以下选项: 代码块: String baseUrl = "http://demo.guru99.com/test/login.html"; driver.get(baseUrl); // Get the WebElement corresponding to the Email Address(TextField) WebElement email = driver.findElement(By.id("email")); // Get
- 代码块:
String baseUrl = "http://demo.guru99.com/test/login.html"; driver.get(baseUrl); // Get the WebElement corresponding to the Email Address(TextField) WebElement email = driver.findElement(By.id("email")); // Get the WebElement corresponding to the Password Field WebElement password = driver.findElement(By.name("passwd"));
- 浏览器快照:
指向WebElement Line时出错,错误是?发布完整堆栈跟踪。@saikiranthotakura检查id为
email
或名称为passwd
的元素是否确实存在/visible@bhusak是的,有id为email和name的元素passwd@Guy错误指向WebElement行和id。我使用.id时也遇到了相同的错误,帮助我out@saikiranthotakura签出更新的答案并让我知道状态。更新后错误:方法cssSelector(字符串)对于类型ByUpgrade to Selenium v3.141未定义。是的,我也升级了
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class A_demo
{
public static void main(String[] args) throws Exception
{
System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
options.setExperimentalOption("useAutomationExtension", false);
WebDriver driver = new ChromeDriver(options);
driver.get("http://demo.guru99.com/test/login.html");
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input#email"))).sendKeys("saikiran_thotakura");
driver.findElement(By.cssSelector("input#passwd")).sendKeys("saikiran_thotakura");
}
}