(求助)selenuim元素定位不到
进行角色新增时,点击“加号”新增按钮,一直定位不到该元素,页面的html代码如图片所示,自己的代码如下,试了好多中方法都不行,求大神指教!// driver.findElement(By.xpath("//i[@class='fa fa-plus']")).click();
// driver.findElement(By.xpath("//i[@id='plus']")).click();
driver.findElement(By.xpath("//a[@id='addTopRoleGroup']")).findElement(By.xpath("//i[@class='fa fa-plus']")).click();
// driver.findElement(By.xpath("//div[@class='tools']/a[@href='#'and class='btn btn-xlue']"));//点击加号按钮
// driver.findElement(By.xpath("//a[@href='#'][@id='addTopRoleGroup']")).click();
// driver.findElement(By.cssSelector("i.fa fa-plus")).click();
沙发,求教 试试
driver.findElement(By.xpath("//div[@class='portlet-title']/div[@class='tools']/a[@id='addTopRpleGroup']")).click;
drvier.findElement(By.xpath("//i[@id='plus']")); 还是不行,报错如下,会不会是其他原因导致的?
Starting ChromeDriver (v2.10.267521) on port 47418
Only local connections are allowed.
FAILED: login
java.lang.IllegalMonitorStateException
at java.lang.Object.wait(Native Method)
at com.pi.page.LoginPage.login(LoginPage.java:37)
at com.pi.TC.LoginTC.login(LoginTC.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1191)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1116)
at org.testng.TestNG.run(TestNG.java:1024)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:112)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:176)
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0 贴一下图中标红的两个类,类中第37跟10行的代码看下,报错是这两行代码
页:
[1]