Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Java环境(Intellij)中使用org.openqa.selenium测试电子应用程序_Java_Selenium_Intellij Idea_Electron_Cucumber Jvm - Fatal编程技术网

在Java环境(Intellij)中使用org.openqa.selenium测试电子应用程序

在Java环境(Intellij)中使用org.openqa.selenium测试电子应用程序,java,selenium,intellij-idea,electron,cucumber-jvm,Java,Selenium,Intellij Idea,Electron,Cucumber Jvm,是否有一种方法可以在Java环境中为电子应用程序使用cucumber和selenium webdriver创建自动化场景 我在上找到了一些Node.js解决方案,但我更喜欢Java 谢谢。您可以将电子浏览器与一起使用。尝试使用类似的设置创建WebDriver: // If chromediver executable is not in your project directory, // point to it with this system variable System.setPro

是否有一种方法可以在Java环境中为电子应用程序使用
cucumber
selenium webdriver
创建自动化场景

我在上找到了一些
Node.js
解决方案,但我更喜欢Java


谢谢。

您可以将电子浏览器与一起使用。尝试使用类似的设置创建WebDriver:

// If chromediver executable is not in your project directory, 
//  point to it with this system variable
System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe"); 

Map<String, Object> chromeOptions = new HashMap<String, Object>();
chromeOptions.put("binary", "path/to/electron/binary");
chromeOptions.put("args", Arrays.asList(" path-to-electron-app"));
//eg.: chromeOptions.put("binary", "D:\\electron-quick-start\\node_modules\\electron-prebuilt\\dist\\electron.exe");
//     chromeOptions.put("args", Arrays.asList(" D:\\electron-quick-start"));
//  for some reason the app arg needs to follow a space on my Windows machine

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("chromeOptions", chromeOptions);
capabilities.setBrowserName("chrome");

WebDriver driver = new ChromeDriver(capabilities);
//如果chromediver可执行文件不在项目目录中,
//用这个系统变量指向它
System.setProperty(“webdriver.chrome.driver”,“D:\\chromedriver.exe”);
Map chromeOptions=new HashMap();
chromeOptions.put(“二进制”、“路径/到/电子/二进制”);
chromeOptions.put(“args”,Arrays.asList(“电子应用程序路径”);
//例如:chromeOptions.put(“二进制”,“D:\\electron快速启动\\node\u模块\\electron预构建\\dist\\electron.exe”);
//chromeOptions.put(“args”,Arrays.asList(“D:\\electron快速启动”);
//由于某些原因,应用程序arg需要在我的Windows计算机上的空格后面
DesiredCapabilities=新的DesiredCapabilities();
能力。设置能力(“色度选项”,色度选项);
能力。setBrowserName(“chrome”);
WebDriver=新的ChromeDriver(功能);

非常直截了当的回答,对我帮助很大。非常感谢。