[英]I couldnt find the fault in my code for login page test with selenium java
package automation;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class MainPage {
private final WebDriver driver;
public MainPage(WebDriver driver) {
this.driver = driver;
}
public MainPage loginAs(String username, String password) {
driver.get("URL");
driver.findElement(By.name("email")).sendKeys("username");
driver.findElement(By.name("password")).sendKeys("password");
driver.findElement(By.className("login")).click();
return new MainPage(driver);
}
public static void main(String[] args) {
System.setProperty("webdriver.genko.driver", "C:\\Users\\Guest01\\Desktop\\chromedriver");
MainPage login = new MainPage(new ChromeDriver());
login.loginAs("qa@gmail.com", "123456");
}
}
I tried to test login function for the web site and wrote above code for it. 我试图测试该网站的登录功能,并为此编写了上面的代码。 However, I couldnt find the error on it.
但是,我找不到它的错误。 Can someone help me to figure it out?
有人可以帮我弄清楚吗?
I see a few things wrong with your code: 我发现您的代码有些错误:
System.setProperty("webdriver.genko.driver", "C:\\Users\\Guest01\\Desktop\\chromedriver");
Should be (make sure the chromedriver is the correct file, the windows version usually has an .exe extension.) 应该是(确保chromedriver是正确的文件,Windows版本通常具有.exe扩展名。)
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Guest01\\Desktop\\chromedriver");
You also should navigate the url of the page you want to test using 您还应该浏览要测试的页面的网址
WebDriver driver = new ChromeDriver();
driver.get("http://[enter url here]")
请编写“壁虎驱动程序”而不是“ genko驱动程序”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.