openfin / hello-openfin-selenium-java-example Goto Github PK
View Code? Open in Web Editor NEWExample of Java test code with Chrome Driver on OpenFin Runtime
License: MIT License
Example of Java test code with Chrome Driver on OpenFin Runtime
License: MIT License
Not really a bug but a problem with executing tests on a grid machine.
We are trying to run our tests in parallel on the remote machine, however, we are facing problems as to how to start the application via the Selenium Grid since the project has moved over from the custom chromedriver to the google chromedriver and we are unable to set the binary to OpenFinRVM as we did before.
Is there a workaround or a different procedure to run the application via Grid?
Here is my sample code. It uses TestNG data provider to implement parallelism. The two HelloOpenFin app.json files that i used have different uuid's and devtool ports.
package com.openfin;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class Driver {
@Test(dataProvider = "dp")
public void ap(String a, String b, String c, String d) throws MalformedURLException, InterruptedException {
startSession(a, b, c, d);
}
@DataProvider(name = "dp", parallel = true)
public Object[][] dp() {
String basePath = "C:/hello-openfin-selenium-java-example/lib/";
return new Object[][] {
{ basePath + "OpenFinRVM1.exe", "--config=" + basePath + "apps1.json", "localhost:9090", "http://localhost:9515" },
{ basePath + "OpenFinRVM1.exe", "--config=" + basePath + "apps2.json", "localhost:9091", "http://localhost:9516" } };
}
public void startSession(String a, String b, String c, String d) throws MalformedURLException, InterruptedException {
String execPath = a;
String execArgs = b;
String debuggerAddress = c;
String remoteDriverURL = d;
ChromeOptions options = new ChromeOptions();
options.setBinary(new File(execPath));
options.addArguments(execArgs);
options.setExperimentalOption("debuggerAddress", debuggerAddress);
options.setExperimentalOption("forceDevToolsScreenshot", Boolean.TRUE);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new RemoteWebDriver(new URL(remoteDriverURL), capabilities);
switchWindow(driver, "Hello OpenFin", 30);
driver.findElement(By.id("desktop-notification")).click();
}
public boolean switchWindow(WebDriver webDriver, String windowTitle, int maxWaitInSeconds) throws InterruptedException {
boolean found = false;
long start = System.currentTimeMillis();
while (!found) {
for (String name : webDriver.getWindowHandles()) {
webDriver.switchTo().window(name);
if (webDriver.getTitle().equals(windowTitle)) {
found = true;
break;
}
}
Thread.sleep(1000);
if ((System.currentTimeMillis() - start) > maxWaitInSeconds * 1000) {
break;
}
}
if (!found) {
System.out.println(windowTitle + " not found");
}
return found;
}
}
The first session ran fine but the the driver for second session fails to find the devTools port:
Started chromeDriver local in port 9515
Arguments: -DExecPath=C:\Users\a678343\WebDrivers\RunOpenFin.bat -DExecArgs="--config=https://appPath/app.json" -DDebuggerAddress=9090
Selenium version: 3.141.59
Openfin Desktop application is getting started. Issue occurs at invoking remote web driver.
[driver = new RemoteWebDriver(new URL(remoteDriverURL), options);]
Stack trace:
01:40:40.543 [main] INFO n.t.c.steps.ConsoleLoggingListener - �[91mSTEP ERROR: org.openqa.selenium.InvalidArgumentException: invalid argument: entry 0 of 'firstMatch' is invalid
from invalid argument: cannot parse capability: goog:chromeOptions
from invalid argument: cannot parse debuggerAddress
from invalid argument: must be 'host:port'
Dear openfin experts,
I faced a issue below, hope your resolution, thanks.
issue description:
when navigate to my login page(window) after get driver successfully, i can find element(username), but sendkeys('124') not works. there is no error, it seems windhandle can't control my UI element(login UI)
code:
selenium.WebDriver driver
driver.navigate().to("http://****:8087/login.html");
Actions actions = new Actions(driver);
WebElement login=driver.findElement(By.id("username"));
login.sendKeys(Keys.CONTROL,Keys.chord("a"));
login.sendKeys(Keys.BACK_SPACE);
actions.moveToElement(driver.findElement(By.id("username"))).sendKeys("124").perform()
my application window information:
{
"uuid": "app_shell",
"name": "app_shell",
"url": "http://:8087/provider.html",
"parentName": "app_shell",
"parentUUID": "app_shell",
"childCount": 1,
"windowInfo": {
"size": "533w333h",
"position": "(7,7)",
"monitor": ""
},
"showing": false,
"subRows": [
{
"uuid": "fmo_app_shell",
"name": "internal-generated-window-d7fc4026-396d-4f73-88e7-4b278c41afd5",
"url": "http://*:8087/login.html",
"parentName": "app_shell",
"parentUUID": "app_shell",
"childCount": 1,
"windowInfo": {
"size": "400w374h",
"position": "(153,440)",
"monitor": ""
},
"showing": true
}
]
}
I am unable to use Actions class in openFin Selenium + JAVA, is this possible here??? -
OpenFin Version - 9.61.38.43
ChromeDriver Version - 2.33.506120
Chrome Version - 61.0.3163.100
Also to add the selenium native methods to click() do not work here
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.