如何解决“软件包org.openqa.selenium.winium不存在”的错误?

时间:2018-09-11 07:34:34

标签: java selenium automation winium

我正在使用 Winium工具进行自动化。我在jar文件下面将其包含在我的项目的类路径中,

  
      
  1. selenium-server-standalone-3.14.0.jar
  2.   
  3. testng-7.0.0-beta1.jar
  4.   
  5. winium-elements-desktop-0.1.0-1.jar
  6.   
  7. winium-elements-desktop-0.2.0-1.jar
  8.   

Java安装版本 :1.8

当我尝试编译程序时,出现以下错误。

D:\Incidents\Winium_213716\TestProjects\winium-desktop-sample-project-master\winium-desktop-sample-project-master\src\main\java>javac sampleTest.java
sampleTest.java:44: error: package org.openqa.selenium.winium does not exist
import org.openqa.selenium.winium.DesktopOptions;
                             ^
sampleTest.java:45: error: package org.openqa.selenium.winium does not exist
import org.openqa.selenium.winium.WiniumDriver;
                             ^
sampleTest.java:52: error: cannot find symbol
DesktopOptions options= new DesktopOptions();
^
symbol:   class DesktopOptions
location: class sampleTest
sampleTest.java:52: error: cannot find symbol
DesktopOptions options= new DesktopOptions();
                          ^
symbol:   class DesktopOptions
location: class sampleTest
sampleTest.java:55: error: cannot find symbol
WiniumDriver driver=new WiniumDriver(new 
URL("http://localhost:9999"),options);
  ^
symbol:   class WiniumDriver
location: class sampleTest
sampleTest.java:55: error: cannot find symbol
WiniumDriver driver=new WiniumDriver(new 
URL("http://localhost:9999"),options);
                       ^
symbol:   class WiniumDriver
location: class sampleTest
6 errors

下面是我的Java代码

import java.io.IOException;
import java.net.URL;
import org.openqa.selenium.winium.DesktopOptions;
import org.openqa.selenium.winium.WiniumDriver;
import org.testng.annotations.Test;

public class sampleTest 
{
 @Test
 public void test() throws IOException{
 DesktopOptions options= new DesktopOptions();
 options.setApplicationPath("C:\\WINDOWS\\system32\\notepad.exe");
  try{
  WiniumDriver driver=new WiniumDriver(new 
  URL("http://localhost:9999"),options);
  driver.findElementByClassName("Edit").sendKeys("This is 
 sample test");
  driver.close();
 }
 catch(Exception e){
 System.out.println(e.getMessage());
}
}

2 个答案:

答案 0 :(得分:0)

您需要Winium web driver罐子用于上述进口

答案 1 :(得分:0)

winium-webdriver-0.1.0-1-sources.jar此jar文件是必需的。它只包含您所缺少的“ org.openqa.selenium.winium”软件包。

如果这是一个Maven项目,请尝试将其添加为Maven依赖项,或者在maven Central中搜索以下依赖项并下载为zip。提取并添加到项目的构建路径=> Java构建路径->库。

<dependency>
    <groupId>com.github.2gis.winium</groupId>
    <artifactId>winium-webdriver</artifactId>
    <version>0.1.0-1</version>
</dependency>