Jump to content

WebDriver UDF (W3C compliant version) - 2024/09/21


Danp2
 Share

Recommended Posts

  • 2 weeks later...

excuse me,

Where is the location of the chrome browser defined?

If my chrome browser is not in the default installation location【C:\ Program Files (x86)\ Google\ Chrome\ Application\ 71.0.3578.98\ chrome.exe】,

how should I specify the specific path to "chrome.exe" in my code?

Link to comment
Share on other sites

On 4/23/2019 at 3:10 AM, Danp2 said:

@Letraindusoir This has been previously discussed. See search results here.

I was busy with some other things last week and put the matter on hold for the time being.Today I tested the code, but it didn't work. The code is as follows:
#include "wd_core.au3"

Local $sDesiredCapabilities

$_WD_DEBUG = False

SetupChrome()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://www.88countryclub.co.kr/")
$hwnd = WinWaitActive("88")
WinSetState($hwnd, "", @SW_MAXIMIZE)

Sleep(1000)
ControlSend($hwnd, "", "", "^f")

Func SetupChrome()
_WD_Option('Driver', 'S:\Web_Driver\chromedriver.exe')
;_WD_Option('binary_location', 'S:\Browsers\Google\Chrome68\chrome.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path=' & @ScriptDir & '\chrome.log')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true,"binary_location":"S:\Browsers\Google\Chrome68\chrome.exe"}}}}'
EndFunc

I put the path of "chrome.exe" in two different locations,but neither succeeded in opening the browser.I still don't know what to do.

Link to comment
Share on other sites

40 minutes ago, Letraindusoir said:
I put the path of "chrome.exe" in two different locations.....

After several tests, I solved the problem myself. It should be inserted into "$sDesiredCapabilities", and in addition, the string must be escaped, that is,"\"  need to be written as "\\".

Link to comment
Share on other sites

Two more problems were found during today's testing of the code:

1, using a Firefox browser test, each time open a browser would be created a new browser process instance:

   20190430141038.png.723d5fdca7e29cb6eabdd814db8fae45.png

   how to control it to open in the new Tab?

2, Test with a Chrome browser, there are more problems:

    (1), if there is no existing Chrome browser, it can open the URL; If a Chrome browser process already exists, it would open a new TAB, and show in the address bar " Data:," but can't open the site

20190430141714.png.63fed6fc893ca30076a10496c9e119ca.png

    (2), Chrome  browser always prompts: Chrome is being controlled by automatic test software.

          It is said that  can add the option "disable-infobars" to solve this problem, but do not know how to add.

Link to comment
Share on other sites

2 hours ago, Letraindusoir said:

using a Firefox browser test, each time open a browser would be created a new browser process instance:

 how to control it to open in the new Tab?

Sorry, but it isn't clear exactly what you're attempting to do. When describing an issue, please post code showing what you have tried.

As far as attaching to an existing FireFox browser, try searching this thread for the phrase "--connect-existing" to see how it's done.

2 hours ago, Letraindusoir said:

if there is no existing Chrome browser, it can open the URL; If a Chrome browser process already exists, it would open a new TAB, and show in the address bar " Data:," but can't open the site

Again, I can't diagnose what might be going wrong without some code. Also, be sure to post the results from the Scite output window.

2 hours ago, Letraindusoir said:

Chrome  browser always prompts: Chrome is being controlled by automatic test software.

 It is said that  can add the option "disable-infobars" to solve this problem, but do not know how to add.

Use the forum search feature to find multiple instances of using this option. :thumbsup:

Link to comment
Share on other sites

6 hours ago, Danp2 said:

please post code showing what you have tried.

The code is as follows:

#include "wd_core.au3"
Local $sDesiredCapabilities
$_WD_DEBUG = False
SetupChrome()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://www.88countryclub.co.kr/")
$hwnd = WinWaitActive("88")
WinSetState($hwnd, "", @SW_MAXIMIZE)
Sleep(1000)
ControlSend($hwnd, "", "", "^f")
Func SetupChrome()
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path=' & @ScriptDir & '\chrome.log')
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true}}}}'
EndFunc

If a Chrome browser process already exists,"chrome.log " show that:

Quote

[1556638929.643][INFO]: Launching chrome: "chrome.exe" 
--disable-background-networking 
--disable-client-side-phishing-detection
--disable-default-apps 
--disable-hang-monitor 
--disable-popup-blocking 
--disable-prompt-on-repost 
--disable-sync 
--disable-web-resources 
--enable-automation
--enable-logging 
--force-fieldtrials=SiteIsolationExtensions/Control 
--ignore-certificate-errors 
--load-extension="X:\MESS\TEMP\USER\scoped_dir2956_15868\internal" 
--log-level=0 
--metrics-recording-only 
--no-first-run 
--password-store=basic 
--remote-debugging-port=12279 
--test-type=webdriver 
--use-mock-keychain 
--user-data-dir="X:\MESS\TEMP\USER\scoped_dir2956_12958" 
data:,


 

 

Edited by Letraindusoir
Link to comment
Share on other sites

18 hours ago, Danp2 said:

@Letraindusoir Chrome doesn't allow you to connect to an existing instance via the webdriver.

Note: I haven't tried launching Chrome with script #1 and then interacting with this instance from script #2 by sharing the session id between scripts.

It seems that I still know too little, and I have to study hard and familiarize myself with it.:sweating:

Link to comment
Share on other sites

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions":{"w3c": true,"pageLoadStrategy":"none"}}}}'
Quote

[1556847178.757][INFO]: RESPONSE InitSession unknown error: cannot parse capability: goog:chromeOptions
from unknown error: unrecognized chrome option: pageLoadStrategy

Does "chromedriver" not support the use of "pageLoadStrategy"?

Link to comment
Share on other sites

  • Danp2 changed the title to WebDriver UDF (W3C compliant version) - 2024/09/21
  • Melba23 pinned this topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...