Is this tutorial still considered to be a reliable method of using Selenium with CEF? I've had some really non-deterministic behavior: in some cases, the example "test" works fine and in some, it crashes. Below is an example code. Perhaps I've done something wrong?
- Code: Select all
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class TestSloba {
public static void main(String[] args) {
WebDriver driver = null;
try{
System.setProperty("webdriver.chrome.driver", "/home/debian-tp/Desktop/selenium_test/chromedriver_linux64/chromedriver");
ChromeOptions options = new ChromeOptions();
// Cefclient won't start ptoperly without these options
options.addArguments("--no-sandbox");
options.addArguments("--disable-extensions");
String pathToBinary = "/home/debian-tp/Desktop/cef_binary_3.3578.1861.g1992780_linux64/cef_binary_3.3578.1861.g1992780_linux64//build/tests/cefclient/Debug/cefclient";
options.setBinary(pathToBinary);
options.addArguments("--remote-debugging-port=8088");
driver = new ChromeDriver(options);
sleep(2000);
driver.get("http://192.168.15.166:8080");
sleep(2000);
System.out.println("Title: " + driver.getTitle());
sleep(2000);
System.out.println("Title test 1: " + (driver.getTitle().trim().equals("Page redirection test")));
sleep(2000);
} catch (Exception e) {
System.out.println("EXCEPTION: " + e.toString());
}finally {
if (driver != null)
driver.quit();
System.exit(0);
}
}
static void sleep(int time) {
try { Thread.sleep(time); } catch (InterruptedException e) {}
}
}
I replace the path argument with the path to my other executable when I try to test this example with my custom CEF project.
It mostly works with cefclient: sometimes it crashes but that seems to be related to the command line arguments that I pass.
Also, when I don't get the crash with my application, I see no window. On cefclient, I see a window just fine.
So, am I doing something wrong? If you need more info, let me know!
EDIT:
Adding the crash message I get:
- Code: Select all
Starting ChromeDriver 2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926) on port 1988
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
EXCEPTION: org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed
(chrome not reachable)
(The process started from chrome location /home/debian-tp/Desktop/cross_platform_new_cef/build/AplWrapperTestInCLinux/Debug/apltestc_linux is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.9.0-8-amd64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.05 seconds
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:42:28.403Z'
System info: host: 'debian-tp', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.0-8-amd64', java.version: '1.8.0_181'
Driver info: driver.version: ChromeDriver