2017-06-27 3 views
0

Ich bin neu in der Selen-Automatisierung, ich habe damit begonnen, einige Bildschirme meiner Anwendung zu automatisieren, indem ich Selen in die Anwendung selbst integriert habe.Zugriff auf Funktion beim Erstellen von Maven-Selen-Anwendung

Ich habe hinzugefügt folgende abhängigkeit

<dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-chrome-driver</artifactId> 
      <version>3.4.0</version> 
     </dependency> 

     <dependency> 
      <groupId>org.testng</groupId> 
      <artifactId>testng</artifactId> 
      <version>6.11</version> 
     </dependency> 

     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-support</artifactId> 
      <version>2.29.1</version> 
     </dependency> 

und den Code zurückzukehren um sich einzuloggen und klicken Sie auf eine Menü-Taste chromedriver als Gebrüll

 class LoginTest{ 

     // defined a WebDriver named driver 

     private WebDriver driver; 

     @Test 
      public void loginTest() 
        throws InterruptedException 
      { 
       // open login page 
       driver.get("https://localhost:8080/adct/#/"); 
       // maximize the window 
       driver.manage().window().maximize(); 
       // type in user name 
       driver.findElement(By.id("username")).sendKeys("abcd"); 
       // type in user password 
       driver.findElement(By.id("password")).sendKeys("abcd"); 
       // click on the submit button 
       driver.findElement(By.id("loginBtn")).click(); 

       try 
       { 
        WebDriverWait wait = new WebDriverWait(driver, 15); 
        WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='menuBtnId']"))); 
        element.click(); 
        Thread.sleep(3000); 

        ImportTestCase testCase = new ImportTestCase(); 
        testCase.setFileName("Login Success"); 
        testcases.add(testCase); 

       } 
       catch(Exception e) 
       { 
        ImportTestCase testCase = new ImportTestCase(); 
        testCase.setFileName("Login Failure"); 
        testcases.add(testCase); 
       } 
     } 

     } 

Aber während die Anwendung den Aufbau mit mvn sauber installieren Ich bin Geeting folgende Ausnahme

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project BillWebApplication: Compilation failure 
[ERROR] /home/user/SVN/Source/BillWebApplication/src/main/java/com/billing/dct/automation/service/LoginTest.java:[25,32] error: cannot access Function 
[ERROR] -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project BillWebApplication: Compilation failure 
/home/user/SVN/Source/BillWebApplication/src/main/java/com/billing/dct/automation/service/LoginTest.java:[25,32] error: cannot access Function 

    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(LifecycleModuleBuilder.java:108) 
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76) 
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361) 
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155) 
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584) 
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213) 
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:157) 
    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.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.CompilationFailureException: Compilation failure 
/home/user/SVN/Source/BillWebApplication/src/main/java/com/billing/dct/automation/service/LoginTest.java:[25,32] error: cannot access Function 

    at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:729) 
    at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128) 
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) 
    ... 19 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 

Ich bin durch die link gegangen, aber immer noch hat es das Problem nicht gelöst und was auch immer ich versuche, die Ausnahme ist auf den folgenden Frieden der Linie.

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='menuBtnId']"))); 

ist es eine Alternative für die oben genannte Linie oder gibt es eine Lösung, es zu beheben. Jede Hilfe wird geschätzt.

Antwort

0

Ich habe durch Zugabe folgende Abhängigkeit in pom.xml ohne jede Codeänderung gelöst

 <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-remote-driver</artifactId> 
      <version>3.0.1</version> 
     </dependency> 
Verwandte Themen