Jump to content

WebDriver UDF (W3C compliant version) - 2024/02/19


Danp2
 Share

Recommended Posts

I want to use a user agent.
 

On 22/11/2018 at 4:54 AM, Danp2 said:

@pempemHY I tried running your code, but it seemed to get hung up in this area --

$button_go = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@id='u_0_1w']")
_WD_ElementAction($sSession, $button_go, 'click')

Not sure what this should be doing. Would really help if you could provide a much simpler example to review.

 

Link to comment
Share on other sites

In the future, please use the following method for posting code --

 

19 minutes ago, truong2301 said:

How to sent text to input

You're using the wrong value (name) for the $sCommand parameter. For an example of the proper technique, look at the DemoElements function in wd_demo.

P.S. Your questions would better fit into the GH&S thread.

Link to comment
Share on other sites

Hi Dan,

I try to use your UDF, but error happened

#include "wd_core.au3"
#include "wd_helper.au3"

Local $sSession
Local $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}'

_WD_Option('Driver', 'geckodriver.exe')
_WD_Option('DriverParams', '--log trace')
_WD_Option('Port', 4444)


_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "http://google.com")

_WD_DeleteSession($sSession)
_WD_Shutdown()

Win 10, 64bit

Firefox 55 64bit

driver.PNG

console.PNG

Link to comment
Share on other sites

Hi Paul,

1 hour ago, PaulC said:

Is the use of the lastest version of FF a mandatory requirement for using this UDF?

No, but as you've seen it may not work with older versions since the goal is to be compatible with the latest w3c standards.

If you can, try your code with the latest  FF and let me know the outcome.

Dan

Link to comment
Share on other sites

18 minutes ago, Danp2 said:

Hi Paul,

No, but as you've seen it may not work with older versions since the goal is to be compatible with the latest w3c standards.

If you can, try your code with the latest  FF and let me know the outcome.

Dan

I've tried with Chrome and have good result, thank you Dan.

Link to comment
Share on other sites

Hi Dan,

After I updated the WebDriver UDF and ChromeDriver to the latest versions, I see a behaviour I did not experience before.

When _WD_GetSource or _WD_FindElement funtions are called while an alert box is open, the alert box is automatically closed. It is not an "accept". It just closes. I did not test other functions except these two. Please have a look.

Thank you always.

CY Cho

 

#include "wd_core.au3"
#include "wd_helper.au3"

$url = 'http://cafe.golf.sbs.co.kr/html/front/club/board/view.jsp?bd_no=93083&site_id=7146&bltin_no=27423995&page=1&sc_flag=all&sc_keyword='

Local $sDesiredCapabilities
$_WD_DEBUG = False
SetupChrome()
_WD_Startup()

_WD_Navigate($sSession, $url)
Sleep(5000)
$sSource = _WD_GetSource($sSession)


Func SetupChrome()
    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--log-path=' & @ScriptDir & '\chrome.log')

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars"] }}}}'
EndFunc

 

Edited by CYCho
Inserted a reproducer code.
Link to comment
Share on other sites

The above code is just a reproducer showing disappearance of an alert box upon encounter with _WD_GetSource. My actual codes look like below where I keep "accepting" 2 or 3 alerts  until I find a certain string in the source. This code used to work with no problem, but now I cannot "accept" the alerts because _WD_GetSource in the while loop kills the alert before I can accept it.

 

While Not StringInStr(_WD_GetSource($sSession), "ReservationCancel")
    If _WD_Alert($sSession, "status") Then
        _WD_Alert($sSession, "accept")
    EndIf
    Sleep(500)
WEnd

 

Link to comment
Share on other sites

 
Hi Dan,
we have the problem that every time a new temporary rust-xxx ... profile is created, but we need some plugins and addons in the profile. We would therefore like to use a previously created custom profile as a template or our profile itself. We have been testing for hours but each time a new rust-xxx ... profile was created although our profile is also used (because it can not be deleted), but the program simply stops after starting Firefox. Where is the issue, how can we use our profile and the program continues?
Best regards Hans Jürgen
 
$sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true,"moz:firefoxOptions":{"binary":"C:\\Program Files\\Mozilla Firefox AU3\\firefox.exe","args":["-profile", "C:\\Users\\workaholicus.BLP2011\\AppData\\Local\\Temp\\FFAU3ProfileZ"]}}}'

 

Link to comment
Share on other sites

Hi Hans,

This issue was previously disccussed here, so may want to review that (in particular, the reference to the issue on Github).

Not sure if this will work for you, but here's how I run with my standard user profile in Firefox --

  • Start Firefox manually with the "--marionette" option
  • Use these settings to connect to the existing browser instance
_WD_Option('DriverParams', '--log trace --connect-existing  --marionette-port 2828')

 

 Dan

Link to comment
Share on other sites

  • Danp2 changed the title to WebDriver UDF (W3C compliant version) - 2024/02/19
  • 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...