Jump to content

WebDriver UDF (W3C compliant version) - 06/04/2022


Recommended Posts

  • 3 weeks later...
  • Replies 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

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 f

Latest update just released. See below for change log.  

Latest update just released. See below for change log.  

Posted Images

Hi all & Dan,

What's the trick to getting Webdriver to wait until a page is fully loaded. This  example is of a website which has been giving me a problem all morning and maybe you can see it taking a while to load when you test this example (if you even have to test it since you might know why without testing)

 

   SplashTextOn('Notice', 'Loading Website ... ',500,150,default,default,33,'Arial',14)
        _WD_Navigate($sSession, 'https://www.tutorialspoint.com/html/html_frames.htm')
        _WD_LoadWait($sSession, 300,40000)
   SplashOff()

Before the 40 seconds it moves on but the page isn't fully loaded

 

Strange thing is that this doesn't seem to work right either (as far as I understand)

Func ExampleNoLoad()
    $iResult = 0
    HotkeySet ( "+{ESC}", "_Exit" ) ;+shift !alt ^ctrl #winkey
    $hTimer = TimerInit()
    SplashTextOn('Notice', 'Loading Website ... ',500,150,default,default,33,'Arial',14)
        _WD_Navigate($sSession, GUICtrlRead($XpathUrl))
        While $iResult = 0
            $iResult = _WD_LoadWait($sSession, 300,3000)
            ConsoleWrite("-Waiting " & Round(TimerDiff($hTimer)/1000,1) & @TAB & "Failed->" & @TAB & "$_WD_ERROR_Timeout=" & @error & @CRLF)
        WEnd
    SplashOff()
EndFunc ;==ExampleNoLoad
Func _Exit()
    ConsoleWrite("Started Func _Exit()" & @CRLF)
    _WD_DeleteSession($sSession)
    _WD_Shutdown()
    Exit
EndFunc   ;==>Exit

The above code loops and checks every 3 seconds for a _WD_LoadWait success but until that happens it prints out every timeout failure error to the console. Strange that it keeps displaying 0 as the timeout error yet the top left of chrome is still showing the tab is loading and it doesn't seem to make a difference or move forward after the tab loaded.

Thanks for all help and tips.

Edited by NassauSky
More info included
Link to post
Share on other sites

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By levila
      Hi Guys, i just do some codding to automate login to some of the web.
      I manage to do the script but somehow after script done, some weird box popup. and keep looping until i close the main chrome.exe

      here is my code. kinldy pls assist, im very new to webdriver udf.
      #NoTrayIcon #include "wd_core.au3" #include "wd_helper.au3" $_WD_DEBUG = $_WD_DEBUG_None ; You could also use $_WD_DEBUG_Error Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://someoftheweb.com") _ChromeSetInputValueByName($sSession, "inputName", "Username") _ChromeSetInputValueById($sSession, "inputPassword", "Password") _ChromeSetMouseClick($sSession, "submit", "click") _WD_Shutdown() 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":["--no-sandbox"]}}}}' EndFunc Func _ChromeSetInputValueByName($sSession,$name,$Value) $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='"&$name&"']") _WD_ElementAction($sSession,$sButton,'value', $Value) EndFunc Func _ChromeSetInputValueById($sSession,$Id,$Value) $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='"&$Id&"']") _WD_ElementAction($sSession,$sButton,'value', $Value) EndFunc Func _ChromeSetMouseClick($sSession,$Id,$Value) $sButton = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//button[@type='"&$Id&"']") _WD_ElementAction($sSession, $sButton, 'click', $Value) EndFunc  
    • By RohanM
      Hi Team,
      is there is a way to embed the webpage in auto it GUI using webdriver? what I want to do is that, I want to open edge browser inside the AutoIT GUI, in IE we have _IECreateEmbedded function but for the webdriver I am not able to find a function, please help  
      Rohan M
    • By goku200
      I am trying to change the settings of the print option to Save as PDF and its not changing the settings and clicking on the Save button at the bottom. Here is my script that I have written and the format is correct below. Chrome browser I'm using is 97.0 My script was working fine using Chrome 95.0\ Not sure why its not working now
      It finds the print-preview-app element but not the others.
       
    • By goku200
      I am trying to hit the Return key without having to use the Send keys. I have the following code and its not hitting the Return key. Am I missing something?
      ; Press Return $sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE006"},' ; Pause $sAction &= '{"type": "pause", "duration": 500},' ; Release Return $sAction &= '{"type": "keyUp", "value": "\uE006"}]}]}' _WD_Action($sSession, "actions", $sAction)  
    • By goku200
      I'm having an issue with my html paginated table. The script work as expected. It reads the html table and clicks on the Download button. However when it clicks on the next page its not iterating the items. instead it goes to the next URL from the spreadsheet and then iterates through the html table clicking the Download button and so on. Not sure why its doing that. I want it to click the next page and then continue iterating then after it has reached the end of the pagination go to the next url in the spreadsheet and repeat the process. Below is my script. Any help is appreciated 🙂
       
       
×
×
  • Create New...