Jotos Posted October 28 Share Posted October 28 (edited) Hey everyone, I'm trying to get WebDriver up and running, but I’m having trouble getting my custom script to start. Here’s the script I’m using: Spoiler expandcollapse popup#include "wd_helper.au3" #include "wd_capabilities.au3" _Example() Func _Example() # REMARK # This is not functional script # It only shows the concept how to use WebDriver UDF #Region ; initialize webdriver sesion ;~ ; you should take care about download/update dirver ;~ If $IDYES = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON1, "Question", _ ;~ "Do you want to download/update driver ?") Then ;~ _WD_UpdateDriver('chrome') ;~ EndIf ; specify driver, port and other options _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') ; start the driver _WD_Startup() If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's ; create capabilites for session _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'chrome') _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') Local $sCapabilities = _WD_CapabilitiesGet() ; create session with given Capabilities Local $WD_SESSION = _WD_CreateSession($sCapabilities) If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's #EndRegion ; initialize webdriver sesion #Region ; do your's stuff Global Const $sURL = "URL" Global Const $mail = "MAIL" Global Const $pw = "PW1" Global Const $pin = "PW2" ; navigate to some website _WD_Navigate($WD_SESSION, $sURL) If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's ; wait for loading process ends _WD_LoadWait($WD_SESSION, 1000) If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's ; find element Local $sXPath = '//*[@id="Enter user name"]' Local $sElement = _WD_FindElement($WD_SESSION, $_WD_LOCATOR_ByXPath, $sXPath) If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's ; set element _WD_SetElementValue($WD_SESSION, $sElement, $mail) If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's #EndRegion ; do your's stuff #Region ; Clean Up ; on the end session should be deleted _WD_DeleteSession($WD_SESSION) If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's ; and driver should be closed _WD_Shutdown() If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's #EndRegion ; Clean Up EndFunc ;==>_Example The strange thing is that when I run the demo script, it works just fine. But with this script, nothing happens at all—no browser window opens, and there are no errors. Any advice on what might be going wrong or how I can troubleshoot this? Thanks in advance for any help! PS: This is the demo: Spoiler Here its running. Edited October 28 by Jotos Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted October 28 Share Posted October 28 (edited) Hi @Jotos 👋 , change this _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') to this _WD_Option('DriverParams', '--port 9515 --verbose --log-path="' & @ScriptDir & '\chrome.log"') and try again. Explanation: Best regards Sven Edited October 28 by SOLVE-SMART Danp2 1 Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now