Action类在POM中不起作用。我在页面中有一个方法,我试图移动到一个元素,然后单击子选项卡。但它不起作用。这是Page类和测试类,任何人都知道问题是什么
Page Class
public void clickManageCapacityTab() {
actions = new Actions(driver);
log.info("move to account admin tab");
actions.moveToElement(accountAdminTab).perform();
AutoUtility.sleep(1);
log.info("manage capacity tab is clicked");
manageCapacityTab.click();
}
测试类
public class CheckManageCapacity extends BaseTest {
@Test(priority=6, groups={"checkintest"})
private void testCheckManageCapacity() {
LoginPage loginPage = new LoginPage(driver);
loginPage.signInApp(username, password);
NavigationPage navigationPage = new NavigationPage(driver);
navigationPage.clickManageTab();
navigationPage.clickManageCapacityTab();
}
}
以下是我的例外
FAILED: testCheckManageCapacity
org.openqa.selenium.InvalidArgumentException: Could not find webelement key
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'ZAHID-LAPTOP', ip: '192.168.0.10', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=C:\Users\zafaque\AppData\Local\Temp\rust_mozprofile.T1V3FfIgWOuV, rotatable=false, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=54.0.1, platformVersion=10.0, moz:processID=19004.0, browserName=firefox, javascriptEnabled=true, platformName=windows_nt}]
Session ID: 0660b08a-ec93-467b-ae17-ef68624aaae9
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:150)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:115)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:45)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.perform(RemoteWebDriver.java:703)
at org.openqa.selenium.interactions.Actions$BuiltAction.perform(Actions.java:631)
at org.openqa.selenium.interactions.Actions.perform(Actions.java:593)
at page.NavigationPage.clickManageCapacityTab(NavigationPage.java:108)
at script.CheckManageCapacity.testCheckManageCapacity(CheckManageCapacity.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:744)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)