import java.io.File;
public class LoginPage {
private final WebDriver driver;
public LoginPage(WebDriver driver) {
this.driver = driver; }
public void loginAs(String username, String password) {
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
// WebDriver driver = new InternetExplorerDriver(ieCapabilities);
driver.get("https://login.salesforce.com/?locale=uk");
driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
driver.findElement(By.id("username")).sendKeys(username);
driver.findElement(By.id("password")).sendKeys(password);
driver.findElement(By.id("Login")).click();ogin.loginAs("username", "password");}}
}
public static void main(String[] args){
File file = new File("C:/Users/E20039504/Desktop/Selenium Jar/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
LoginPage login = new LoginPage(new InternetExplorerDriver());
login.loginAs("username", "password");
}
}
我正在尝试登录 Salesforce 应用程序,但我的这段代码不起作用。请帮助。