Jump to content

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


Danp2
 Share

Recommended Posts

31 minutes ago, Danp2 said:

The console should be hidden in the current implementation as long as $_WD_DEBUG <> $_WD_DEBUG_Info.

Did this not work for you? Or did you want full debugging but without the console visible?

Didn't realize there was a new version out there.  I was still on V0.1.0.13.  Just updated and you are correct, that does hide when I used the $_WD_DEBUG = $_WD_DEBUG_None

 

Link to comment
Share on other sites

1 hour ago, BigDaddyO said:

I also used an old function from SmOke_N to close chrome since chromedriver.exe spawns child processes that were not closing with the normal _WD_Shutdown()

I haven't experienced this, I'm guessing because I do most of my testing with FF. How would I best observe this scenario?

Link to comment
Share on other sites

13 minutes ago, Danp2 said:

I haven't experienced this, I'm guessing because I do most of my testing with FF. How would I best observe this scenario?

You wouldn't notice unless you looked in the task manager.

I updated the post above to just have the example to show closing spawned chrome processes, so if you run it as-is it will close once finished and there will be no chrome.exe's left in the task manager.

If you put in the _WD_Shutdown()

and comment out the 

;New section since Chromedriver and chrome windows werent closing
;$aSpawnedChildren = _ProcessGetChildren($iPID)          ;Get all processes spawned directly from the Chromedriver.exe
;ProcessClose($iPID)                                                         ;Close the Chromedriver.exe
;For $x = 0 to UBound($aSpawnedChildren) - 1                 ;Move through every child process
;    ProcessClose($aSpawnedChildren[$x][0])                      ;Close the child process
;Next

 

after the script is finished, when you look into the task manager, there will most likely be a few chrome.exe's left open.

Link to comment
Share on other sites

@BigDaddyO From what I can see, the issue you describe is caused by not properly deleting the webdriver session before exiting your script. Try adding the following in lieu of your "new section" code --

_WD_DeleteSession($sSession)
_WD_Shutdown()

P.S. Another update released a little while ago ;)

Link to comment
Share on other sites

Hi @ngocthang26 and welcome to the forums.

I suggest that you re-post you inquiry in the following thread, which is for general help / support. Be sure to include more details in your post so that we can better assist you, such as --

  • Browser you are using
  • Code showing what you have tried thus far
  • etc

Regards,

Dan

 

 

Link to comment
Share on other sites

I am getting an error 

_WD_Startup ==> General Error: Error launching web driver!

Chrome driver chromedriver.exe had been saved into C:\Program Files (x86)\AutoIt3 directory which is mentioned in PATH system veriable. Also the driver could be successfuly launched from cmd window.

Edited by Vitaliy4us
Link to comment
Share on other sites

  • 2 weeks later...
On 18. 1. 2018 at 12:14 AM, Danp2 said:

Introduction

This UDF will allow you to interact with any browser that supports the W3C WebDriver specifications. Supporting multiple browsers via the same code base is now possible with just a few configuration settings.

Requirements

Function List

Core Functions

  • _WD_CreateSession($sDesiredCapabilities='{}')
  • _WD_DeleteSession($sSession)
  • _WD_Status()
  • _WD_Timeouts($sSession, $sTimeouts = '')
  • _WD_Navigate($sSession, $sURL)
  • _WD_Action($sSession, $sCommand)
  • _WD_Window($sSession, $sCommand, $sOption = '')
  • _WD_FindElement($sSession, $sStrategy, $sSelector, $sStartElement = "", $lMultiple = False)
  • _WD_ElementAction($sSession, $sElement, $sCommand, $sOption='')
  • _WD_ExecuteScript($sSession, $sScript, $sArguments="[]")
  • _WD_Alert($sSession, $sCommand, $sOption = '')
  • _WD_GetSource($sSession)
  • _WD_Cookies($sSession, $sCommand, $sOption = '')
  • _WD_Option($sOption, $vValue = "")
  • _WD_Startup()
  • _WD_Shutdown()

Helper Functions

  • _WD_NewTab($sSession, $lSwitch = True)
  • _WD_Attach($sSession, $sString, $sMode = 'title')
  • _WD_LinkClickByText($sSession, $sText, $lPartial = True)
  • _WD_WaitElement($sSession, $sElement, $sStrategy, $sSelector[, $iDelay = 0[, $iTimeout = -1]])
  • _WD_LastHTTPResult()
  • _WD_GetFrameCount()
  • _WD_IsWindowTop()
  • _WD_FrameEnter($sIndexOrID)
  • _WD_FrameLeave()
  • _WD_HighlightElement($sSession, $sElement[, $iMethod = 1])
  • _WD_HighlightElements($sSession, $aElements[, $iMethod = 1])
  • WD_LoadWait($sSession, $iDelay = 0, $iTimeout = -1, $sElement = '')

Source Code

You will always be able to find the latest version in the GitHub Repo 

Help / Support

Please post any questions, suggestions or errors in the GH&S thread.

https://www.autoitscript.com/forum/topic/192730-webdriver-udf-help-support/

 

Hello, all!

I have not time to study your experiments and bugfixes:--).

I am searching for easy, stable, reliable and ready solution of a very simple problem:

Internet browser (say Chrome) is already open (say on www.dpd.cz/data).

And I need fill-in several fields and send with a button, the browser will stay open.

 My solution with VBS and SendKeys does not work perfectly because of diacritics.

 Thanks!

 

 

 

Link to comment
Share on other sites

  • Developers
20 minutes ago, EmilV said:

 

Hello, all!

I have not time to study your experiments and bugfixes:--).

I am searching for easy, stable, reliable and ready solution of a very simple problem:

So your question is  .... what exactly? You want us to do the coding for you or something?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I feel dumb not being able to find this, but where is webdriver.au3?

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to comment
Share on other sites

Click the "Latest version" link in my signature to navigate to the Github site, which is where you will always find the most recent code.

FYI, the file webdriver.au3 no longer exists. It was split into two different files --

  • wd_core.au3 containing the core webdriver functionality
  • wd_helper.au3 containing additional "helper" functions
Link to comment
Share on other sites

On 10/15/2018 at 6:49 AM, Danp2 said:

Click the "Latest version" link in my signature to navigate to the Github site, which is where you will always find the most recent code.

FYI, the file webdriver.au3 no longer exists. It was split into two different files --

  • wd_core.au3 containing the core webdriver functionality
  • wd_helper.au3 containing additional "helper" functions

Ah ok. Thanks man!

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to comment
Share on other sites

Hello,

I was wondering if _WD_Attach is working and you could actually provide a sane example, because as far as I went it only started me a new window and performed  actions that i have expected. But what I really want is to attach to already existing window with some title like "Google"?

Link to comment
Share on other sites

@Peacelover You haven't really given enough information for us to know how to really help you. In general, you can only attach to a browser that was launched by the web driver. There are some exceptions, and I've started a FAQ entry in the GH Wiki to address this situation.

Here's a revised version of the DemoNavigation function from wd_demo.au3 that demonstrates the use of _WD_Attach --

Func DemoNavigation()
    _WD_Navigate($sSession, "http://google.com")
    _WD_NewTab($sSession)
    _WD_Navigate($sSession, "http://yahoo.com")
    _WD_NewTab($sSession)
    _WD_Navigate($sSession, "http://bing.com")

    ConsoleWrite("URL=" & _WD_Action($sSession, 'url') & @CRLF)
    _WD_Attach($sSession, "google.com", "URL")
    ConsoleWrite("URL=" & _WD_Action($sSession, 'url') & @CRLF)
    _WD_Attach($sSession, "yahoo.com", "URL")
    ConsoleWrite("URL=" & _WD_Action($sSession, 'url') & @CRLF)
EndFunc

HTH, Dan

Link to comment
Share on other sites

Hi Dan,
many years we have  automated our access to various portals with Stilgars FFau3 and MozRepl. Recently we had to switch to FirefoxESR, but that does not work anymore with MozRepl since FF_ESR V60. Now we have found your Webdriver UDF and hope to continue working with it.
Our first problem in wd_demo: 

Firefox starts, but $sSession = _WD_CreateSession ($ sDesiredCapabilities)  always returns "".

We suspect that it's up to the definitions (see below) at SetupGecko or problems with FF Portable.

(Windows8.1, Firefox Portable V62, AutoIt V3.3, Webdriver 0.1.0.15).

_______________________________________________________________________________________________________________

_WD_Option('Driver', 'C:\Portable\PortableApps\FirefoxPortable\geckodriver.exe')
_WD_Option('DriverParams', '--log trace')
_WD_Option('Port', 4444)

$sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true,"moz:firefoxOptions":{"binary":"C:\\Portable\\PortableApps\\FirefoxPortable\\FirefoxPortable","args":["-profile","C:\\Portable\\PortableApps\\FirefoxPortable\\Data\\Profile\\"]}}}'

_______________________________________________________________________________________________________________

I am sorry I don't know how to insert the code like the others do ;-)

Thanks for any help.

Link to comment
Share on other sites

Hi @HJL,

I believe that your desired capabilities needs adjusted, as the binary option needs to include the executable name as well. FWIW, it didn't work In my brief testing when I used the FirefoxPortable.exe from Portableapps.com. However, I did get it to work by changing to the actual executable found in the App\Firefox64 subdirectory.

Dan

Link to comment
Share on other sites

  • 2 weeks later...
On 26/10/2018 at 1:45 AM, Danp2 said:

Hi @HJL,

I believe that your desired capabilities needs adjusted, as the binary option needs to include the executable name as well. FWIW, it didn't work In my brief testing when I used the FirefoxPortable.exe from Portableapps.com. However, I did get it to work by changing to the actual executable found in the App\Firefox64 subdirectory.

Dan

Hi Dan, i got the error : _WD_Startup ==> Invalid value: Location for Web Driver not set. this is my very short code: 

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


Local $first, $ssession
;~ SetupChrome()
_WD_Startup()
$ssession = _WD_CreateSession($first)
_WD_Navigate($ssession,"")
_WD_Shutdown()

If i enable SetupChrome() then it get error undefined function. Sorry for my bad english and thank you so much for this UDF

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...