简体   繁体   English

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

[英]Testing Electron application with org.openqa.selenium in a Java environment (Intellij)

Is there a way to create automated scenarios using cucumber and selenium-webdriver in Java environment for an Electron application?有没有办法在 Java 环境中为 Electron 应用程序使用cucumberselenium-webdriver创建自动化场景?

I found some Node.js solutions on electron.atom.io , but I would prefer Java.我在electron.atom.io上找到了一些Node.js解决方案,但我更喜欢 Java。

Thanks.谢谢。

You can use Electron browser with ChromeDriver .您可以使用带有ChromeDriver 的Electron 浏览器。 Try creating WebDriver with similar setup:尝试使用类似的设置创建 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);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium: '包 org.openqa.selenium 不存在' - Selenium: 'package org.openqa.selenium does not exist' Selenium 安装失败,缺少 org.openqa.selenium - Selenium installation failing with missing org.openqa.selenium 错误:包 org.openqa.selenium 不存在 - error : package org.openqa.selenium doesn't exist Jmeter:Class 或未找到变量:org.openqa.selenium - Jmeter: Class or variable not found: org.openqa.selenium 错误:Jmeter:类型变量声明:未找到类或变量:org.openqa.selenium:在行:4 - Error: Jmeter: Typed variable declaration : Class or variable not found: org.openqa.selenium : at Line: 4 Java Selenium 错误:线程“main”中的异常 java.lang.NoClassDefFoundError:org/openqa/selenium/HasAuthentication,IntelliJ IDEA - Java Selenium Error: Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/HasAuthentication, IntelliJ IDEA org.openqa.selenium.NoSuchElementException WebDriver是否在Java中? - org.openqa.selenium.NoSuchElementException WebDriver in Java? Selenium - 无法导入 package 'org.openqa.selenium.environment' - Selenium - Not able to import package 'org.openqa.selenium.environment' java.lang.ClassCastException:org.openqa.selenium.By $ ById无法转换为org.openqa.selenium.WebElement - java.lang.ClassCastException: org.openqa.selenium.By$ById cannot be cast to org.openqa.selenium.WebElement “org.openqa.selenium.By”中的“id(java.lang.String)”不能应用于“(org.openqa.selenium.By)” - 'id(java.lang.String)' in 'org.openqa.selenium.By' cannot be applied to '(org.openqa.selenium.By)'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM