Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arguments/Options not passed on to Selenium 4.x #25

Open
Mecanik opened this issue Jan 9, 2022 · 8 comments
Open

Arguments/Options not passed on to Selenium 4.x #25

Mecanik opened this issue Jan 9, 2022 · 8 comments

Comments

@Mecanik
Copy link
Contributor

Mecanik commented Jan 9, 2022

Hi, thanks for updating this old script to latest selenium. There are a few issues though, like some arguments and options not being passed on. Tested with Chrome 97.0.4692.0.

Args:

--window-size=1280,1024

Selenium says: "???" = not even there

Capabilities:

common.SetAcceptSslCerts(true);

Selenium says: "acceptInsecureCerts:false"

There are probably more I just need to test.

@Mecanik
Copy link
Contributor Author

Mecanik commented Jan 9, 2022

After double checking, it seems that none of my Args have been set, like --user-data-dir; it's default:

[1] --allow-pre-commit-input
[2] --disable-background-networking
[3] --disable-backgrounding-occluded-windows
[4] --disable-client-side-phishing-detection
[5] --disable-default-apps
[6] --disable-hang-monitor
[7] --disable-popup-blocking
[8] --disable-prompt-on-repost
[9] --disable-sync
[10] --enable-automation
[11] --enable-blink-features=ShadowDOMV0
[12] --enable-logging
[13] --log-level=0
[14] --no-first-run
[15] --no-service-autorun
[16] --password-store=basic
[17] --remote-debugging-port=0
[18] --test-type=webdriver
[19] --use-mock-keychain
[20] --user-data-dir=C:\Users\MECANI~1\AppData\Local\Temp\scoped_dir12844_1938992320

Still investigating why...

@Mecanik
Copy link
Contributor Author

Mecanik commented Jan 9, 2022

I really have no idea how you/others used Chrome like this, because I recalled that chromeOptions is needed to pass on arguments and such. When I pulled your repo I thought it is more up to date, but it seems not.

Anyway, please add the following in chrome.h:

struct ChromeOptions : JsonObject 
{
	WEBDRIVERXX_PROPERTIES_BEGIN(ChromeOptions)
	
	/*
		List of command-line arguments to use when starting Chrome. 
		Arguments with an associated value should be separated by a '=' sign (e.g., ['start-maximized', 'user-data-dir=/tmp/temp_profile']).
	*/		
	WEBDRIVERXX_PROPERTY(Args, "args", std::vector<std::string>)
	/*
	Path to the Chrome executable to use (on Mac OS X, this should be the actual binary, not just the app. e.g., '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome')
	*/
	WEBDRIVERXX_PROPERTY(Binary, "binary", std::string)
	/* 
		A list of Chrome extensions to install on startup. Each item in the list should be a base-64 encoded packed Chrome extension (.crx) 
	*/
	WEBDRIVERXX_PROPERTY(Extensions, "extensions", std::vector<std::string>)
	/* 
		A dictionary with each entry consisting of the name of the preference and its value. 
		These preferences are applied to the Local State file in the user data folder.
	*/
	WEBDRIVERXX_PROPERTY(LocalState, "localState", JsonObject)
	/*
		A dictionary with each entry consisting of the name of the preference and its value. 
		These preferences are only applied to the user profile in use. See the 'Preferences' file in Chrome's user data directory for examples.
	*/
	WEBDRIVERXX_PROPERTY(Prefs, "prefs", JsonObject)
	/*
		If false, Chrome will be quit when ChromeDriver is killed, regardless of whether the session is quit. If true, Chrome will only be quit if the session is quit (or closed). 
		Note, if true, and the session is not quit, ChromeDriver cannot clean up the temporary user data directory that the running Chrome instance is using.
	*/
	WEBDRIVERXX_PROPERTY(Detach, "detach", bool)
	/* 
		An address of a Chrome debugger server to connect to, in the form of <hostname/ip:port>, e.g. '127.0.0.1:38947'
	*/
	WEBDRIVERXX_PROPERTY(DebuggerAddress, "debuggerAddress", std::string)
	/*
		List of Chrome command line switches to exclude that ChromeDriver by default passes when starting Chrome.  Do not prefix switches with --.
	*/
	WEBDRIVERXX_PROPERTY(ExcludeSwitches, "excludeSwitches", std::vector<std::string>)
	/*
		Directory to store Chrome minidumps . (Supported only on Linux.)
	*/
	WEBDRIVERXX_PROPERTY(MinidumpPath, "minidumpPath", std::string)
	/*
		A dictionary with either a value for “deviceName,” or values for “deviceMetrics” and “userAgent.” Refer to Mobile Emulation for more information.
	*/
	WEBDRIVERXX_PROPERTY(MobileEmulation, "mobileEmulation", JsonObject)
	/*
		An optional dictionary that specifies performance logging preferences
	*/
	WEBDRIVERXX_PROPERTY(PerfLoggingPrefs, "perfLoggingPrefs", chrome::PerfLoggingPrefs)
	
	WEBDRIVERXX_PROPERTIES_END()
};

And:

struct Chrome : Capabilities { // copyable
	Chrome(const Capabilities& defaults = Capabilities())
		: Capabilities(defaults) {
		SetBrowserName(browser::Chrome);
		SetVersion("");
		SetPlatform(platform::Any);
	}

	// See https://sites.google.com/a/chromium.org/chromedriver/capabilities for details
	WEBDRIVERXX_PROPERTIES_BEGIN(Chrome)
	
	WEBDRIVERXX_PROPERTY(ChromeOptions, "chromeOptions", ChromeOptions)

	WEBDRIVERXX_PROPERTIES_END()
};

@GermanAizek
Copy link
Owner

@Mecanik,
You've already tested your changes?
Chrome support is bad because I'm not actively using it for webdriver.

@Mecanik
Copy link
Contributor Author

Mecanik commented Jan 9, 2022

@Mecanik, You've already tested your changes? Chrome support is bad because I'm not actively using it for webdriver.

Yes, working perfectly. Everything is taken into account by Selenium.

BTW - What do you use? Firefox?

@GermanAizek
Copy link
Owner

Firefox?

At the moment functionally it suits me. I don't need additional chrome features yet.

@Mecanik
Copy link
Contributor Author

Mecanik commented Jan 9, 2022

Firefox?

At the moment functionally it suits me. I don't need additional chrome features yet.

I see, I would like to try Firefox as well. Can you share some Args, etc?

@Mecanik
Copy link
Contributor Author

Mecanik commented Jan 9, 2022

Now I am being stupid... I did not even notice you already added the correct options for Chrome. I do apologize for this, I had the old repo from the other author in my PC and I confused it with yours... :(

@vega0
Copy link

vega0 commented Sep 23, 2022

How you connected this sources to the roject?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants