下面的代码输入用户名/密码,然后单击登录按钮,但是即使等待20秒也无法加载下一页,该页面仍停留在URL上。我正在使用Mac,其他人遇到此问题吗?
我尝试过thread.sleep和显式等待
这是代码的一部分: 公共类测试{
static WebDriver driver;
String baseURL = "http://automationpractice.com/index.php";
static WebDriverWait wait = new WebDriverWait(driver, 20);
ECommerceNotLoggedInClass initialPage;
ECommerceLoginPageClass loginPage;
MyAccountPage testMyAccount;
@BeforeTest
public void setup() {
driver = new ChromeDriver();
driver.get(baseURL);
}
@Test(priority = 0)
public void verifyPageTitleAndClickForLogin() {
initialPage = new ECommerceNotLoggedInClass(driver);
Assert.assertEquals(initialPage.getTitle(), "My Store");
initialPage.clickSignIn();
}
@Test(priority = 1)
public void signInAndCheckRightPage() {
loginPage = new ECommerceLoginPageClass(driver);
waitUnitElementPresent(loginPage.loginInputForm);
Assert.assertEquals(loginPage.getLogInPageTitle(), "Login - My Store");
loginPage.login();
在控制台中看到的错误消息: org.openqa.selenium.TimeoutException:预期条件失败:等待Proxy元素的可见性:DefaultElementLocator'By.cssSelector:#login_form'(尝试15秒,间隔500毫秒)
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:95)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:272)
at Tests.waitUnitElementPresent(Tests.java:62)
at Tests.signInAndCheckRightPage(Tests.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:73)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
由以下原因引起:org.openqa.selenium.NoSuchElementException:没有这样的元素:无法找到元素:{“ method”:“ css选择器”,“ selector”:“#login_form”} (会议信息:chrome = 75.0.3770.100) 有关此错误的文档,请访问:https://www.seleniumhq.org/exceptions/no_such_element.html 构建信息:版本:'3.141.59',修订版本:'e82be7d358',时间:'2018-11-14T08:17:03' 系统信息:主机:'Zornitsas-MacBook-Air.local',ip:'2601:246:5600:305a:0:0:0:974c%en0',操作系统名称:'Mac OS X',os.arch :'x86_64',os.version:'10 .12.6',java.version:'1.8.0_201' 驱动程序信息:org.openqa.selenium.chrome.ChromeDriver 功能{acceptInsecureCerts:false,browserName:chrome,browserVersion:75.0.3770.100,chrome:{chromedriverVersion:75.0.3770.8(681f24ea911fe7 ...,userDataDir:/ var / folders / wf / dbzc1bjx021 ...},goog:chromeOptions:{ debuggerAddress:本地主机:50995},javascriptEnabled:true,networkConnectionEnabled:false,pageLoadStrategy:正常,平台:MAC,platformName:MAC,代理:Proxy(),setWindowRect:true,strictFileInteractability:false,超时:{隐式:0,pageLoad: 300000,脚本:30000},unhandledPromptBehavior:关闭并通知} 会话ID:79b9669510b099033ef4c3ec52baa8df ***元素信息:{Using = css选择器,值=#login_form}