Closed cosoc closed 1 year ago
@cosoc, thank you for creating this issue. We will troubleshoot it as soon as we can.
Triage this issue by using labels.
If information is missing, add a helpful comment and then I-issue-template
label.
If the issue is a question, add the I-question
label.
If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted
label.
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable G-*
label, and it will provide the correct link and auto-close the
issue.
After troubleshooting the issue, please add the R-awaiting answer
label.
Thank you!
Hi, @cosoc. Please follow the issue template, we need more information to reproduce the issue.
Either a complete code snippet and URL/HTML (if more than one file is needed, provide a GitHub repo and instructions to run the code), the specific versions used, or a more detailed description to help us understand the issue.
Note: If you cannot share your code and URL/HTML, any complete code snippet and URL/HTML that reproduces the issue is good enough.
Reply to this issue when all information is provided, thank you.
果您无法共享您的代码
public ChromeDriver getDefaultBrowserChrome(boolean isHeadless, Integer width, Integer height) {
System.setProperty("webdriver.chrome.driver", "/home/dev/chromedriver/chromedriver");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--user-data-dir=/home/dev/chromedriver/data");
chromeOptions.setExperimentalOption("excludeSwitches",new String[]{"enable-automation"});
chromeOptions.setExperimentalOption("useAutomationExtension", "False");
if (isHeadless) {
chromeOptions.addArguments("--headless");
}
ChromeDriver chromeDriver = new ChromeDriver(chromeOptions);
// 设置尺寸
if ( width != null && width > 0 ) {
if (height != null || height <= 0) {
height = 800;
}
org.openqa.selenium.Dimension targetSize = new Dimension(width,height);
chromeDriver.manage().window().setSize(targetSize);
}
chromeDriver.executeScript("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})");
return chromeDriver;
}
You cannot remove the webdriver
property by the way
chromeDriver.executeScript("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})");
What values are you using to invoke getDefaultBrowserChrome
? Why don't you provide a complete script?
This is an encapsulated public method that can be directly called in the main method. There are many places to call, so no call logic code is provided. This code can open the Chrome browser if the idea is running, and the function is normal. However, if the mvn clean package is packaged and the java-jar test.jar is run, an error will be reported. And it only prompts the appeal information and does not stack the information. I use jdk17 to run the jar package. I tried to use the same driver and modify system permissions as the development environment, but still reported an error. Very distressed! Thank you for your reply!
I understand, but how can I triage something if I cannot execute the code with the same parameters you are using? Why don't you provide the main
you are referring to?
I ask because I already tried the code and it worked for me, so I guess something is different in the way it is being invoked.
The reason is that jre uses a customized runtime and does not set the correct permissions (Linux), but why not print the information related to permissions?
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
java jar package will error
How can we reproduce the issue?
Relevant log output
Operating System
debian11
Selenium version
4.8.1
What are the browser(s) and version(s) where you see this issue?
100.0.4896.127
What are the browser driver(s) and version(s) where you see this issue?
The development environment is normal but jar not run
Are you using Selenium Grid?
No response