在Java环境中使用org.openqa.selenium测试Electron应用程序(Intellij) [英] Testing Electron application with org.openqa.selenium in a Java environment (Intellij)

查看:177
本文介绍了在Java环境中使用org.openqa.selenium测试Electron应用程序(Intellij)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以在Java环境中使用黄瓜 selenium-webdriver 为Electron应用程序创建自动化方案?

Is there a way to create automated scenarios using cucumber and selenium-webdriver in Java environment for an Electron application?

我在Node.js 解决方案。 io / docs / v0.36.7 / tutorial / using-selenium-and-webdriver / rel = nofollow> electron.atom.io ,但我更喜欢Java。

I found some Node.js solutions on electron.atom.io, but I would prefer Java.

谢谢。

推荐答案

您可以将Electron浏览器与 ChromeDriver 。尝试使用类似的设置创建WebDriver:

You can use Electron browser with ChromeDriver. Try creating WebDriver with similar setup:

// 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);

这篇关于在Java环境中使用org.openqa.selenium测试Electron应用程序(Intellij)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆