I need help with setting up ChromeDriver in Selenium WebDriver.
I have downloaded the latest version of ChromeDriver and added the path to the exe to my PATH environment variable.
However, when I try to run any scripts they fail on the line
driver = new ChromeDriver();
An instance of Chrome opens with a black screen and the address set as "data;," and I get a popup stating:
"Chrome Automation Extension has crashed".
Continuing from that point, I get the following exception details:
unknown error: unable to discover open pages
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.19 seconds
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:03:33'
As I say, I've got the latest version of ChromeDriver and I have checked that Chrome is currently running the latest version so I know it isn't an issue with outdated versions of either.
I'm sure it must be something simple which I'm overlooking, but I just can't think what. Does anyone have any ideas?
Edit
Here's the log for the case, where Capability is not passed as a variable:
[0.885][INFO]: COMMAND InitSession {
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": [ ],
"extensions": [ ]
},
"platform": "ANY",
"version": ""
}
}
[0.886][INFO]: Populating Preferences file: {
"alternate_error_pages": {
"enabled": false
},
"autofill": {
"enabled": false
},
"browser": {
"check_default_browser": false
},
"distribution": {
"import_bookmarks": false,
"import_history": false,
"import_search_engine": false,
"make_chrome_default_for_user": false,
"show_welcome_page": false,
"skip_first_run_ui": true
},
"dns_prefetching": {
"enabled": false
},
"profile": {
"content_settings": {
"pattern_pairs": {
"https://*,*": {
"media-stream": {
"audio": "Default",
"video": "Default"
}
}
}
},
"default_content_setting_values": {
"geolocation": 1
},
"default_content_settings": {
"geolocation": 1,
"mouselock": 1,
"notifications": 1,
"popups": 1,
"ppapi-broker": 1
},
"password_manager_enabled": false
},
"safebrowsing": {
"enabled": false
},
"search": {
"suggest_enabled": false
},
"translate": {
"enabled": false
}
}
[0.889][INFO]: Populating Local State file: {
"background_mode": {
"enabled": false
},
"ssl": {
"rev_checking": {
"enabled": false
}
}
}
[0.936][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --load-extension="C:\Users\Rory\AppData\Local\Temp\scoped_dir10152_5411\internal" --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12607 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\Rory\AppData\Local\Temp\scoped_dir10152_31299" data:,
[61.070][INFO]: RESPONSE InitSession unknown error: unable to discover open pages
Related
I am using:
Java 17
Quarkus 2.12.0.Final
Jolt 0.1.7
graalvm-ce-22.0.0
Native image
mvn clean package -DskipTests -Pnative -Dquarkus.native.container-build=true
Using this transformer:
{
"operation": "default",
"spec": {
"user": {
"enabled": true
}
}
}
When a run the application using non-native image, it works!!
When a run the application the application with native image, occurs this error:
at com.bazaarvoice.jolt.common.DeepCopy.simpleDeepCopy(DeepCopy.java:53)
at com.bazaarvoice.jolt.defaultr.MapKey.applyLiteralKeyToContainer(MapKey.java:57)
at com.bazaarvoice.jolt.defaultr.MapKey.applyChild(MapKey.java:44)
at com.bazaarvoice.jolt.defaultr.Key.applyChildren(Key.java:162)
at com.bazaarvoice.jolt.defaultr.MapKey.applyLiteralKeyToContainer(MapKey.java:67)
at com.bazaarvoice.jolt.defaultr.MapKey.applyChild(MapKey.java:44)
at com.bazaarvoice.jolt.defaultr.Key.applyChildren(Key.java:162)
at com.bazaarvoice.jolt.Defaultr.transform(Defaultr.java:242)
at com.bazaarvoice.jolt.Chainr$ContextualTransformAdapter.transform(Chainr.java:113)
at com.bazaarvoice.jolt.Chainr.doTransform(Chainr.java:240)
at com.bazaarvoice.jolt.Chainr.transform(Chainr.java:180)
at com.mypackage.myclass.Play.run(Play.java:20)
at io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder$1.processRequest(AmazonLambdaRecorder.java:170)
at io.quarkus.amazon.lambda.runtime.AbstractLambdaPollLoop$1.run(AbstractLambdaPollLoop.java:130)
at java.lang.Thread.run(Thread.java:833)
at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:704)
at com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:202)
caused by: java.io.InvalidClassException: java.lang.Boolean; no valid constructor
at java.io.ObjectStreamClass$ExceptionInfo.newInvalidClassException(ObjectStreamClass.java:174)
at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:921)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2236)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1744)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:514)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:472)
at com.bazaarvoice.jolt.common.DeepCopy.simpleDeepCopy(DeepCopy.java:50)
... 26 more
As java.lang.Boolean has no default constructor, I tried registerForReflection, but not works too.
EDIT
I have found I workaround:
{
"operation": "default",
"spec": {
"user": {
"enabled": "true"
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"user": {
"enabled": "=toBoolean"
}
}
}
EDIT 2
This also happen with other values like Integer, Long, because they do not have default constructor.
Those errors happen because how the copy is made:
Look here, but I am Newbie in native image, so I don't know why this kind of copy does not work.
I'm creating a cluter in EMR aws and when spark runs my application I'm getting error below:
Exception in thread "main" java.lang.UnsupportedClassVersionError:
com/example/demodriver/MyClassFromJAR has been compiled by a more recent version of the Java Runtime (class file version 55.0),
this version of the Java Runtime only recognizes class file versions up to 52.0
I'm using releaseLabel emr-6.5.0 on clusters and My driver jar is built in java11
How run java11 application in EMR? Or this error is about anything else?
In the most recent versions of EMR, java 11 is installed. To enable it, you can provide the following configuration.
[
{
"Classification": "spark-env",
"Configurations": [
{
"Classification": "export",
"Properties": {
"JAVA_HOME": "/usr/lib/jvm/java-11-amazon-corretto.x86_64"
}
}
]
},
{
"Classification": "spark-defaults",
"Properties": {
"spark.executorEnv.JAVA_HOME": "/usr/lib/jvm/java-11-amazon-corretto.x86_64"
}
}
]
This does not seem to be documented.
The defaultJavaOptions and extraJavaOptions might contain incompatible options for java 11 which you still might need to adapt/update.
Here is the full configuration including the necessary JVM options:
[
{
"Classification": "spark-env",
"Configurations": [
{
"Classification": "export",
"Properties": {
"JAVA_HOME": "/usr/lib/jvm/java-11-amazon-corretto.x86_64"
}
}
]
},
{
"Classification": "spark-defaults",
"Properties": {
"spark.executorEnv.JAVA_HOME": "/usr/lib/jvm/java-11-amazon-corretto.x86_64",
"spark.driver.defaultJavaOptions": "-XX:OnOutOfMemoryError='kill -9 %p' -XX:MaxHeapFreeRatio=70",
"spark.executor.defaultJavaOptions": "-verbose:gc -Xlog:gc*::time -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:OnOutOfMemoryError='kill -9 %p' -XX:MaxHeapFreeRatio=70 -XX:+IgnoreUnrecognizedVMOptions"
}
}
]
For running Spark (3.3.0) on EMR 6 (6.9.0) I had to provide the following (note the additional "hadoop-env" and the empty "Properties" elements):
[
{
"Classification": "hadoop-env",
"Configurations": [
{
"Classification": "export",
"Configurations": [],
"Properties": {
"JAVA_HOME": "/usr/lib/jvm/java-11-amazon-corretto.x86_64"
}
}
],
"Properties": {}
},
{
"Classification": "spark-env",
"Configurations": [
{
"Classification": "export",
"Configurations": [],
"Properties": {
"JAVA_HOME": "/usr/lib/jvm/java-11-amazon-corretto.x86_64"
}
}
],
"Properties": {}
},
{
"Classification": "spark-defaults",
"Properties": {
"spark.executorEnv.JAVA_HOME": "/usr/lib/jvm/java-11-amazon-corretto.x86_64"
}
}
]
I am using below code for Firefox launch in locally and through VM machine. But I am unable to launch firefox through VM machine.
case FIREFOX:
browserType = BrowserTypes.FIREFOX;
System.setProperty("webdriver.gecko.driver", "Drivers/geckodriver.exe");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setCapability("marionette", true);
firefoxOptions.setAcceptInsecureCerts(true);
if(isRemote) {
webDriver = launchGridDriver(firefoxOptions, configProps.getNodeUrl());
Reporter.log("Running test on Grid, in browser \'Firefox\'", true);
} else {
webDriver = new FirefoxDriver(firefoxOptions);
Reporter.log("Running test in browser \'FIREFOX\'", true);
}
break;
private WebDriver launchGridDriver(Capabilities capabilities, String url){
try{
return new RemoteWebDriver(new URL(url), capabilities);
} catch(Exception e){
Reporter.log("There was an error setting up the remote WebDriver.");
e.printStackTrace();
return null;
}
}
I am able to launch firefox locally and when I just trying to launch in remote below error is getting.
org.openqa.selenium.SessionNotCreatedException: Unable to create session from {
"desiredCapabilities": {
"browserName": "firefox",
"server:CONFIG_UUID": "02c53809-74d8-4b47-95a1-fc97610ba78c",
"moz:firefoxOptions": {
"args": [
],
"prefs": {
}
},
"marionette": true,
"acceptInsecureCerts": true
},
"capabilities": {
"firstMatch": [
{
"acceptInsecureCerts": true,
"browserName": "firefox",
"moz:firefoxOptions": {
"args": [
],
"prefs": {
}
},
"server:CONFIG_UUID": "02c53809-74d8-4b47-95a1-fc97610ba78c"
}
]
}
}
Need Few more inputs.. It looks like the networking issue where your code host is unable to reach the Hub.
Please let me know that :-
Where is the hub VM located, If it is on same machine, do use the IP Bridge Configuration and not NAT.
Do your machine having code and having Hub are on same VLAN.
Where is the Node? You wont be seeing the browser launch on Hub. It will be on node.
getNodeUrl() returns the IP of hub machine.
Firewalls on the hub and node and the code host machine is off (Just to ensure it is not blocking the connection)
Rest code looks fine.
I followed the solution given by #obiwankoban and #SubjectiveReality mentioned at the following link:
How to handle authentication popup in Chrome with Selenium WebDriver using Java
I performed the below steps:
Created a folder called 'Extension'
Created following two files inside Extension folder.
manifest.json
{
"name": "Webrequest API",
"version": "1.0",
"description": "Extension to handle Authentication window",
"permissions": [
"webRequest",
"webRequestBlocking",
""
],
"background": {
"scripts": [
"webrequest.js"
]
},
"manifest_version": 2
}
webrequest.js
chrome.webRequest.onAuthRequired.addListener(function(details){
console.log("chrome.webRequest.onAuthRequired event has fired");
return {
authCredentials: {username: "getestone", password: "Viacom#2020"}
};
},
{urls:["<all_urls>"]},
['blocking']);
Updated Pack extension on chrome browser, post which .crx file gets created.
My Selenium code is as follows:
Selenium code
public class openWebsite {
public static void main(String[] args) {
Properties prop = new Properties();
ChromeOptions options = new ChromeOptions();
File addonpath = new
File("C:\\Users\\10642575\\Desktop\\Work\\Automation\\AuthPopUp\\Extension.crx");
ChromeOptions chrome = new ChromeOptions();
chrome.addExtensions(addonpath);
//options.addArguments("--no-sandbox");
System.setProperty("webdriver.chrome.driver",
"C:\\Users\\10642575\\Desktop\\Work\\Automation\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver(options);
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS) ;
driver.get("https://uat.contentplatform.viacom.com/");
driver.findElement(By.xpath("//input[#type='email']")).sendKeys("getest.one#viacom.com");
driver.findElement(By.xpath("//input[#type='submit']")).click();
}
}
On following the above steps, I still get the server authentication pop up when the website is launched on chrome. Authentication bypass is not working.
PLZ HELP
When running a Java program from the command line, assertions can be enabled with the -enableassertions option for the java command. Running this program would then (and only then) fail with an AssertionError:
public class App {
public static void main(String[] args) throws Exception {
foo(2);
}
private static void foo(int x) {
assert x > 5;
System.out.println(x);
}
}
How can this be done when running a Java program in Visual Studio Code with the Java Extension Pack?
Visual Studio Code manages launch configurations in the launch.json file in the project folder root.
The -enableassertions option can be added there with the vmArgs key like this:
{
"configurations": [
{
"type": "java",
"name": "My App",
"request": "launch",
"mainClass": "App",
"projectName": "my-app",
"vmArgs": "-enableassertions"
}
]
}