我们已成功通过Selenium登录应用程序,但我们无法从那里去任何地方。
Selenium从那时起停止工作。
这是我们用于进入应用程序的代码:
public class testclass {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "C:\\Selenium-java-3.0.1\\geckodriver.exe");
ProfilesIni profile = new ProfilesIni();
// this will create an object for the Firefox profile
FirefoxProfile myprofile = profile.getProfile("default");
// this will Initialize the Firefox driver
WebDriver driver = new FirefoxDriver(myprofile);
driver.get("https://applicationURL/Forms");
driver.findElement(By.xpath(".//*[@id='login']")).click();
driver.findElement(By.xpath(".//*[@id='login']")).sendKeys("username");
driver.findElement(By.xpath(".//*[@id='password']")).click();
driver.findElement(By.xpath(".//*[@id='password']")).sendKeys("password");
driver.findElement(By.xpath(".//*[@id='btnlogin']")).click();
[这是Selenium刚停止的地方]
driver.findElement(By.xpath(".//*[@id='panelBarMiddleSearchPanels_i0_txtAttr_1_22']")).click();
driver.findElement(By.xpath(".//*[@id='panelBarMiddleSearchPanels_i0_txtAttr_1_22']")).sendKeys("LTR*");
}
}
然后我不知道在哪里可以找到Selenium的错误?因为它只是停在需要进一步发展的地方。
我不确定是否重要提及,但我们正在通过VPN工作。我不确定它是否与此问题有关 - Can't open browser with Selenium after Firefox update
答案 0 :(得分:1)
尝试使用以下更新的代码:
public class testclass {
public static void main(String[] args) throws Exception{
System.setProperty("webdriver.gecko.driver", "C:\\Selenium-java-3.0.1\\geckodriver.exe");
ProfilesIni profile = new ProfilesIni();
// this will create an object for the Firefox profile
FirefoxProfile myprofile = profile.getProfile("default");
// this will Initialize the Firefox driver
WebDriver driver = new FirefoxDriver(myprofile);
driver.get("https://applicationURL/Forms");
driver.findElement(By.xpath(".//*[@id='login']")).click();
driver.findElement(By.xpath(".//*[@id='login']")).sendKeys("username");
driver.findElement(By.xpath(".//*[@id='password']")).click();
driver.findElement(By.xpath(".//*[@id='password']")).sendKeys("password");
driver.findElement(By.xpath(".//*[@id='btnlogin']")).click();
Thread.sleep(7000);
driver.findElement(By.xpath(".//*[@id='panelBarMiddleSearchPanels_i0_txtAttr_1_22']")).click();
driver.findElement(By.xpath(".//*[@id='panelBarMiddleSearchPanels_i0_txtAttr_1_22']")).sendKeys("LTR*");
}
希望它会对你有所帮助。