geb selenium点击不适用于不在视图中的元素

时间:2017-12-06 17:53:56

标签: selenium selenium-webdriver groovy automated-tests geb

我知道有类似的问题被提出但是解决方案没有帮助。example 1example 2

我想点击链接,该链接位于页面的底部。我可以从浏览器控制台单击该链接。问题是我无法点击geb和selenium的链接。当我将required属性设置为true而不单击我的测试过程没有问题。这意味着geb在selenium中看到了元素,我无法理解为什么我无法点击。

以下是我的代码示例:

class MyPage extends Page {

   static at = { mybutton }

   static content = {

    mybutton(wait:true, required:true) { $('a',href:"/folder/folder1/main.jsp?page=changes")}

   }

  }

这是我测试它的方式:

class MyTestSuite extends GebReportingSpec {
  def 'MyTestFunction' () {
  ...
  then:
  at MyPage
  and:''
  mybutton.click() // unknown error: Element is not clickable at point (699, 2280)
 }
}

然后我尝试滚动到元素并单击使用交互但这不起作用,因为交互返回null。

and:
interact {
   moveToElement(mybutton)
}

这是堆栈跟踪。第77行是mybutton.click()所在的动作。

   Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 40.669 
sec <<< FAILURE! - in myTestSuite
  MyTestFunction(myTestSuite)  Time elapsed: 27.308 sec  <<< ERROR!
  org.openqa.selenium.WebDriverException: 
  unknown error: Element is not clickable at point (699, 2280)
  (Session info: chrome=62.0.3202.94)
  (Driver info: chromedriver=2.27.440174 
  (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 6.1.7601 
SP1 
  x86_64) (WARNING: The server did not provide any stacktrace information)
   Command duration or timeout: 98 milliseconds
  Build info: version: '3.3.1', revision: '5234b325d5', time: '2017-03-10 
  09:10:29 +0000'
   System info: host: 'MyPCyyyyy', ip: 'xx.xx.xxx.xxx', os.name: 'Windows 
 7', 
   os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_144'
   Driver info: org.openqa.selenium.chrome.ChromeDriver
   Capabilities [{applicationCacheEnabled=false, rotatable=false, 
  mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome=
  {chromedriverVersion=2.27.440174 
 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9), 
  userDataDir=MyDir}, takesHeapSnapshot=true, pageLoadStrategy=normal, 
  databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, 
  version=62.0.3202.94, platform=XP, browserConnectionEnabled=false, 
  nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, 
   webStorageEnabled=true, browserName=chrome, takesScreenshot=true, 
  javascriptEnabled=true, cssSelectorsEnabled=true, 
  unexpectedAlertBehaviour=}]
   Session ID: 6e14ddb8c01ae705bd907a56fd2eba35
   at myTestSuite. MyTestFunction(myTestSuite.groovy:77)


 Results :

 Tests in error: 
 myTestSuite. MyTestFunction:77 » WebDriver unknow...

 Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-
 plugin:2.19:test (default-test) on project geb-maven-example: There are 
 test 
 failures.
 [ERROR] 
 [ERROR] Please refer to D:\eclipse-jee-workspace\folderTest\target\surefire-
reports for the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute 
goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test (default-test) 
on project geb-maven-example: There are test failures.



Please refer to D:\eclipse-jee-workspace\folderTest\target\surefire-reports 


for the individual test results.
 at 





org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)


at




    org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at 



 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at 

org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(Lifecyc

leModuleBuilder.java:116)


 at  
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecyleModuleBuilder.java:80)
at  `org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)`


at



org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)


    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
     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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at 
    org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at 




 org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
   Caused by: org.apache.maven.plugin.MojoFailureException: There are test 
  failures.

      Please refer to D:\eclipse-jee-workspace\folderTest\target\surefire-
   reports for the individual test results.
    at 








 org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:91)
    at 








     org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:318)
        at 







 org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditions
   Checked(AbstractSurefireMojo.java:880)
    at 


 org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:739)
    at 





 org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPlugin
 Manager.java:134)
    at 





 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 20 more
       [ERROR] 
       [ERROR] Re-run Maven using the -X switch to enable full debug logging.
       [ERROR] 
       [ERROR] For more information about the errors and possible solutions, 
   please 
          read the following articles:
       [ERROR] [Help 1] 
       http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException` 

0 个答案:

没有答案