Jump to content

JugglingCoder

Members
  • Posts

    16
  • Joined

  • Last visited

Everything posted by JugglingCoder

  1. Thank you for your suggestion argumentum but at this time "maybe adding a software NIC emulator could allow" seems a bit complicated for me. localhost sites run fine in FireFox and I re-checked the adapters settings to make sure it wasn't turning off when disconnected, etc. My Desktop loads the webdriver just fine when all connections are off so... either it's a windows 11 thing (Desktop is windows 10) or something specific to the tablets setup. However, as mentioned, localhost websites run just fine in WAMP when disconnected using manually launched FireFox in the tablet so.... who knows....
  2. Thank you for your suggestion argumentum. I, "Disconnected" from the internet > then loaded WAMP > WAMP loaded successfully and localhost sites ran just fine. "Turned Off" WiFi > then loaded WAMP > Wamp loaded successfully and localhost sites ran just fine. unfortunately... that doesn't seem to be the issue.
  3. I made a quick video of running the the program on desktop and tablet. For various reasons I'll remove the video in a few weeks but if you want to check it out: on YouTube:
  4. Program Ran > this is the Console Output I'll post both the console output for when I have an internet connection = #1 and after I turn off the internet connection = #2 #1 - Console Output - Internet connection ON = Success >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" /ErrorStdOut "C:\Game Show\Game Controller.au3" _WD_Option ==> Success [0] : Parameters: Option=Driver Value=udf\geckodriver.exe _WD_GetFreePort ==> Success [0 / 4444] : Parameters: MinPort=4444 MaxPort=4500 _WD_Option ==> Success [0] : Parameters: Option=Port Value=4444 _WD_CapabilitiesStartup: #150 : > {"capabilities":"{}"} > IsObj = 1 _WD_CapabilitiesAdd: #179 : $key = alwaysMatch $value1 = firefox $value2 = _WD_CapabilitiesAdd: #207 : $_WD_NOTATION__MATCHTYPE = [capabilities][alwaysMatch] $_WD_NOTATION__SPECIFICVENDOR = ["moz:firefoxOptions"] _WD_CapabilitiesAdd ==> Success [0] : Successfully used [alwaysMatch] with specified browser: firefox _WD_CapabilitiesAdd: #179 : $key = browserName $value1 = firefox $value2 = _WD_CapabilitiesAdd: #219 #277 : $key = browserName $value1 = firefox $value2 = $s_Notation = [capabilities][alwaysMatch]["browserName"] <<<< firefox _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_CapabilitiesAdd: #179 : $key = acceptInsecureCerts $value1 = True $value2 = _WD_CapabilitiesAdd: #219 #277 : $key = acceptInsecureCerts $value1 = True $value2 = $s_Notation = [capabilities][alwaysMatch]["acceptInsecureCerts"] <<<< True _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_CapabilitiesAdd: #179 : $key = prefs $value1 = browser.link.open_newwindow $value2 = 2 _WD_CapabilitiesAdd: #254 #277 : $key = prefs $value1 = browser.link.open_newwindow $value2 = 2 $s_Notation = [capabilities][alwaysMatch]["moz:firefoxOptions"]["prefs"][browser.link.open_newwindow] <<<< 2 _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_GetFreePort ==> Success [0 / 4444] : Parameters: MinPort=4444 MaxPort=Default _WD_IsLatestRelease ==> Success [0] : True _WD_Startup: OS: WIN_11 X64 26100 _WD_Startup: AutoIt: 3.3.16.1 _WD_Startup: Webdriver UDF: 1.4.0 (Up to date) _WD_Startup: WinHTTP: 1.6.4.2 _WD_Startup: Driver: udf\geckodriver.exe (64 Bit) _WD_Startup: Params: _WD_Startup: Port: 4444 _WD_Startup: Command: "udf\geckodriver.exe" _WD_Startup ==> Success [0] __WD_Post: URL=HTTP://127.0.0.1:4444/session; Data={ "capabilities":{ "alwaysMatch":{ "browserName":"firefox", "acceptInsecureCerts":true, "moz:firefoxOptions":{ "prefs":{ "browser.link.open_newwindow":2 } } } } } __WD_Post ==> Success [0] : HTTP status = 200 ResponseText={"value":{"sessionId":"e5fc24dc-0147-4c15-bc0b-0d29beb73154","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"134.0.2","moz:accessibilityChecks":false,"moz:buildID":"20250120135430","moz:geckodriverVersion":"0.36.0","moz:headless":false,"moz:platformVersion":"10.0","moz:processID":12772,"moz:profile":"C:\\Users\\USER\\AppData\\Local\\Temp\\rust_mozprofileWZzFdm","moz:shutdownTimeout":60000,"moz:webdriverClick":true,"moz:windowless":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0"}}} _WD_CreateSession ==> Success [0] : e5fc24dc-0147-4c15-bc0b-0d29beb73154 __WD_Post: URL=HTTP://127.0.0.1:4444/session/e5fc24dc-0147-4c15-bc0b-0d29beb73154/url; Data={"url":"http://gm_local/app/app_index.php"} __WD_Post ==> Success [0] : HTTP status = 200 ResponseText={"value":null} _WD_Navigate ==> Success [0] : Parameters: URL=http://gm_local/app/app_index.php ================================================ #2 - Console Output - Internet connection OFF = Fail >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" /ErrorStdOut "C:\Game Show\Game Controller.au3" _WD_Option ==> Success [0] : Parameters: Option=Driver Value=udf\geckodriver.exe _WD_GetFreePort ==> Success [0 / 4444] : Parameters: MinPort=4444 MaxPort=4500 _WD_Option ==> Success [0] : Parameters: Option=Port Value=4444 _WD_CapabilitiesStartup: #150 : > {"capabilities":"{}"} > IsObj = 1 _WD_CapabilitiesAdd: #179 : $key = alwaysMatch $value1 = firefox $value2 = _WD_CapabilitiesAdd: #207 : $_WD_NOTATION__MATCHTYPE = [capabilities][alwaysMatch] $_WD_NOTATION__SPECIFICVENDOR = ["moz:firefoxOptions"] _WD_CapabilitiesAdd ==> Success [0] : Successfully used [alwaysMatch] with specified browser: firefox _WD_CapabilitiesAdd: #179 : $key = browserName $value1 = firefox $value2 = _WD_CapabilitiesAdd: #219 #277 : $key = browserName $value1 = firefox $value2 = $s_Notation = [capabilities][alwaysMatch]["browserName"] <<<< firefox _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_CapabilitiesAdd: #179 : $key = acceptInsecureCerts $value1 = True $value2 = _WD_CapabilitiesAdd: #219 #277 : $key = acceptInsecureCerts $value1 = True $value2 = $s_Notation = [capabilities][alwaysMatch]["acceptInsecureCerts"] <<<< True _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_CapabilitiesAdd: #179 : $key = prefs $value1 = browser.link.open_newwindow $value2 = 2 _WD_CapabilitiesAdd: #254 #277 : $key = prefs $value1 = browser.link.open_newwindow $value2 = 2 $s_Notation = [capabilities][alwaysMatch]["moz:firefoxOptions"]["prefs"][browser.link.open_newwindow] <<<< 2 _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_GetFreePort ==> Success [0 / 4444] : Parameters: MinPort=4444 MaxPort=Default _WD_IsLatestRelease ==> General Error [1] _WD_Startup: OS: WIN_11 X64 26100 _WD_Startup: AutoIt: 3.3.16.1 _WD_Startup: Webdriver UDF: 1.4.0 (Update status unknown [1]) _WD_Startup: WinHTTP: 1.6.4.2 _WD_Startup: Driver: udf\geckodriver.exe (64 Bit) _WD_Startup: Params: _WD_Startup: Port: 4444 _WD_Startup: Command: "udf\geckodriver.exe" _WD_Startup ==> Success [0] __WD_Post: URL=HTTP://127.0.0.1:4444/session; Data={ "capabilities":{ "alwaysMatch":{ "browserName":"firefox", "acceptInsecureCerts":true, "moz:firefoxOptions":{ "prefs":{ "browser.link.open_newwindow":2 } } } } } __WD_Post ==> Send / Recv error [6] : HTTP status = 0 ResponseText=WinHTTP request timed out before Webdriver _WD_CreateSession ==> Webdriver Exception [10] Error Creating Session: 10 Exiting. "C:\Game Show\Game Controller.au3" (272) : ==> Error in expression.: MsgBox( $MB_TOPMOST, "Error Creating Session: ", & @error) MsgBox( $MB_TOPMOST, "Error Creating Session: ", ^ ERROR >Exit code: 1 ================ After that, the WebDriver window just stays open with this text: 1741863233031 geckodriver INFO Listening on 127.0.0.1:4444
  5. Thank you everyone for chiming in and trying to help me out, greatly appreciated. I wrote a trivia game in PHP and js and finally got it working great but then realized, "in some situations I may not have internet access" so just for the heck of it I turned OFF internet access and loaded up my AutoIt Script with the WebDriver and... well, as mentioned above, it fails. If you want to see an image to understand what I built, there is an image in this thread: More Info The WAMP installation is identical (including windows hosts file, httpd.conf, etc.) on both the Desktop and the Tablet (Lenovo IdeaPad D330). I meticulously made sure of that. The website (php/js trivia game) runs locally on WAMP perfectly fine when opened manually on firefox (or any brower) on both the Desktop and the Tablet. I.E. the hosts file / WAMP server is running fine on 127.0.0.1 I specifically bought this tablet just to play this game so only Windows 11 running > WAMP > my custom built trivia web game running in FireFox. So the chronological order is > boot up > launch WAMP > wait for WAMP to get up and running successfully > Launch my AutoIt UI which has a button to load up the local site with the geckodriver. The reason I need to use the geckodriver is because the game will be shown on a projector screen and I need to "click" things on the tablet which effect the game screen. Anyway, that's all working fine... just not offline. I tried both a.) just disconnecting from Wifi and b.) disabling the adapter... both cause the WebDriver to fail. If anyone needs more info, let me know and I'll try to provide it. Hoping to get this working... man, don't want to have to re-code this in Unity. ========= Edit; stupid post mistake... and a key point! from: "... I turned on internet access ..." to: "... I turned OFF internet access ..."
  6. More info... I did trials on both my Desktop and Tablet (the tablet is having the issue), see below. It's really strange... Everything works fine on the tablet when my internet connection is on but if I turn it off... ERROR... ================================ Internet Connection > ON ================================ Desktop PC Windows 10 > NO ISSUES, geckodriver runs fine 1741741790835 geckodriver INFO Listening on 127.0.0.1:4444 1741741792524 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "-no-remote" "-profile" "C:\\Users\\USERNAME\\AppData\\Local\\Temp\\rust_mozprofilewPyTsK" Read port: 51001 Tablet Windows 11 > NO ISSUES, geckodriver runs fine 1741741790835 geckodriver INFO Listening on 127.0.0.1:4444 1741741792524 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "-no-remote" "-profile" "C:\\Users\\USERNAME\\AppData\\Local\\Temp\\rust_mozprofilewPyTsK" Read port: 55050 ================================ Internet Connection > Turned OFF ================================ DesktopPC Windows 10 > NO ISSUES, geckodriver runs fine 1741741790835 geckodriver INFO Listening on 127.0.0.1:4444 1741741792524 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "-no-remote" "-profile" "C:\\Users\\USERNAME\\AppData\\Local\\Temp\\rust_mozprofilewPyTsK" Read port: 51001 Tablet Windows 11 > ISSUE, geckodriver FAILS 1741741790835 geckodriver INFO Listening on 127.0.0.1:4444 (This line shows and that's it) (After 30 sec. or so this message pops up) Autoit Error Line 15111 (File MY_EXE_NAME. My exe only has 600 lines of code... so is this an error in the included geckodriver.exe?) Error: Error in expression ================================ My SetupGecko function once again (cleaned up) ================================ Func SetupGecko() _WD_Option('Driver', 'udf\geckodriver.exe') Local $iPort = _WD_GetFreePort(4444, 4500) ; instead of specifing a specific port, this function will find a free port from one of the ports listed _WD_Option('Port', $iPort) ; works great _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'firefox') _WD_CapabilitiesAdd('browserName', 'firefox') _WD_CapabilitiesAdd('acceptInsecureCerts', True) _WD_CapabilitiesAdd("prefs","browser.link.open_newwindow",2) ; WORKS $sCapabilities = _WD_CapabilitiesGet() Return $sCapabilities EndFunc
  7. Here is my full SetupGecko function: Func SetupGecko() ; WAMP "Listen" in "httpd.conf" (C:\wamp\bin\apache\apache2.4.51\conf\httpd.conf) is set as, ; Listen 0.0.0.0:80 ; Listen [::0]:80 _WD_Option('Driver', 'udf\geckodriver.exe') Local $iPort = _WD_GetFreePort(4444, 4500) ; instead of specifing a specific port, this function will find a free port from one of the ports listed _WD_Option('Port', $iPort) ; works great ;_WD_Option('Port', 80) ; not working ;( ;_WD_Option('Port', 4444) ;If @error Then Return SetError(@error, @extended, 0) ;_WD_Option('Port', $iPort) ;_WD_Option('DriverParams', '--port=' & $iPort & ' --log trace') ; WebDriver Capabilities ; See: https://www.autoitscript.com/wiki/WebDriver_Capabilities _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'firefox') _WD_CapabilitiesAdd('browserName', 'firefox') _WD_CapabilitiesAdd('acceptInsecureCerts', True) #comments-start The geckodriver.exe instance was originally opening _blank links in a new TAB (not window), Therefore I opened a manually opened FireFox window > Address bar > about:config > search ""neww" > saw that "browser.link.open_newwindow" = 2 Then I ran the geckodriver.exe and in that instance > Address bar > about:config > search ""neww" > saw that "browser.link.open_newwindow" = 3 to compare them, obviously I need to change the value to "2" so added the line below So... hopefully the line below will change that See: https://support.mozilla.org/en-US/questions/1258193 #comments-end _WD_CapabilitiesAdd("prefs","browser.link.open_newwindow",2) ; WORKED!! Saw the "prefs" example on this page > https://www.autoitscript.com/wiki/ WebDriver_Capabilities#Firefox_Examples _WD_CapabilitiesAdd("ui","prefersReducedMotion", 1) ; Removes address bar > Doesn't Work ;_WD_CapabilitiesAdd('debuggerAddress', 9222) ;_WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing in this demo $sCapabilities = _WD_CapabilitiesGet() ; Below Doesn't work ;$sCapabilities = '{"capabilities":{"alwaysMatch":{"acceptInsecureCerts":true, "pageLoadStrategy":"none", "moz:firefoxOptions": {"args": ["-kiosk", "-private", "-profile", "C:\\Users\\Username\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\Profile.Name"]}}}}' Return $sCapabilities EndFunc ; SetupGecko
  8. My script is running fine. However, if I disconnect from the internet, the UDF WebDriver (geckdriver) doesn't work (see below for output). I have WAMP installed and it's running great so I have a web server on my local machine... so wondering why the geckodriver is not working? Does it really need to connect to the internet to run? It can't run on a local server? I tried something like this: _WD_Option('Port', 80) port 80 being the port for WAMP but that didn't work. It says, "_WD_Startup: Port: 80 (Unavailable)". I'll be honest, I really don't understand the port stuff too much so any help would be appreciated. I need to use this AutoIt/WebDriver App OFFLINE so... hoping there is a solution. Error Output ======= _WD_Option ==> Success [0] : Parameters: Option=Driver Value=udf\geckodriver.exe _WD_Option ==> Success [0] : Parameters: Option=Port Value=80 _WD_CapabilitiesAdd ==> Success [0] : Successfully used [alwaysMatch] with specified browser: firefox _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_CapabilitiesAdd ==> Browser or feature not supported [21] : Not supported KEY parameter ( must be defined in $_WD_KEYS__*** ). $key = ui $value1 = prefersReducedMotion $value2 = 1 _WD_GetFreePort ==> Not found [13 / 80] : Parameters: MinPort=80 MaxPort=Default > No available ports found _WD_IsLatestRelease ==> Success [0] : True _WD_Startup: OS: WIN_10 X64 19045 _WD_Startup: AutoIt: 3.3.16.1 _WD_Startup: Webdriver UDF: 1.4.0 (Up to date) _WD_Startup: WinHTTP: 1.6.4.2 _WD_Startup: Driver: udf\geckodriver.exe (64 Bit) _WD_Startup: Params: _WD_Startup: Port: 80 (Unavailable) _WD_Startup: Command: "udf\geckodriver.exe" _WD_Startup ==> Success [0] __WD_Post ==> Success [0] : HTTP status = 404 _WD_CreateSession ==> Webdriver Exception [10] Error Creating Session: 10 Exiting.
  9. Great, thanks SOLVE-SMART! I will give that code a try in the future and keep note of it. However, I was anxious so just simply switched to Bing Translate which worked fine with the geckodriver.
  10. Thank you for your reply Danp2. Well... that sucks;( Thought there would be a simple solution. I did search quite a bit (always do before posting) and I'll try some more.
  11. Please see the image and code below. In Short WebDriver UDF geckodriver browser is not displaying all elements as regular FireFox browser Details My code is working fine... 1.) it opens the geckodriver 2.) navigates to the translate page, 3.) copy/paste the text, 4.) and it translates into Kanji just fine. However... using the geckodriver browser, the "Romaji" (the English letters/words showing how to say the Kanji in English) text/element is missing. Using a regular browser and translating the text works fine and does show the "Romaji". Anybody have any input as to why this is happening? Am I missing a "_WD_Option" or "_WD_CapabilitiesAdd" that needs to be added? My goal for this little app was to get the Romaji but was very surprised to see... it's not there. Code #include <Constants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> ; ; =========== WEB_DRIVER_UDF_INCLUDES ================================================= #include "udf\wd_helper.au3" #include "udf\wd_capabilities.au3" #include "udf\wd_core.au3" Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Global $sCapabilities ; NEEDED for the GeckoDriver Global $sSession ; NEEDED for the GeckoDriver Global $website = "https://translate.google.co.jp/?hl=en&sl=en&tl=ja" Global $string_to_translate = "The weather is nice today" #comments-start Standard FireFox URL - WORKS, i.e. Romaji Shows https://translate.google.co.jp/?hl=en&sl=en&tl=ja&text=The%20weather%20is%20nice%20today&op=translate Webdriver URL - Same exact URL but Romaji does NOT show https://translate.google.co.jp/?hl=en&sl=en&tl=ja&text=The%20weather%20is%20nice%20today&op=translate #comments-end SetupGecko() _WD_Startup() If @error <> $_WD_ERROR_Success Then Exit MsgBox(0, "Error", "Firefox Driver failed to load") $sSession = _WD_CreateSession($sCapabilities) If @error Then ConsoleWrite("Error Creating Session: " & @error & " Exiting." & @CRLF) MsgBox( $MB_TOPMOST, "Error Creating Session: ", & @error) Exit EndIf sleep(1000) _WD_Navigate($sSession, $website) ; opens a webpage (online or local) > Works WinWaitActive("Google Translate") ClipPut ($string_to_translate) Send("^v") ; "paste" into Google Translate Window #Region FUNCTION_DECLARATION #comments-start ================== Function Declarations START ========================= ============================================================= #comments-end Func SetupGecko() _WD_Option('Driver', 'udf\geckodriver.exe') Local $iPort = _WD_GetFreePort(4444, 4500) ; instead of specifing a specific port, this function will find a free port from one of the ports listed _WD_Option('Port', $iPort) _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'firefox') _WD_CapabilitiesAdd('browserName', 'firefox') _WD_CapabilitiesAdd('acceptInsecureCerts', True) _WD_CapabilitiesAdd("prefs","browser.link.open_newwindow",2) ; WORKED!! Saw the "prefs" example on this page > https://www.autoitscript.com/wiki/WebDriver_Capabilities#Firefox_Examples $sCapabilities = _WD_CapabilitiesGet() Return $sCapabilities EndFunc ; SetupGecko #comments-start ================== Function Declarations END ========================== ============================================================= #comments-end #EndRegion #Region CLEANUP #comments-start ================== Cleanup START ================================= ============================================================= ; Currently not cleaning up so can inspect open window #comments-end ;_WD_DeleteSession($sSession) ;_WD_ShutDown() #EndRegion ;Exit
  12. Final update for this issue. Success! The key was to use an instance of a browser window (in my case FireFox) that was launched by the geckodriver.exe and NOT try to "attach" to an already running instance. After running the FireFox instance I simply used the "_WD_GetElementById" and "_WD_ElementAction" of the WebDriver UDF to click the appropriate divs (wrapped in a tags).
  13. I see, thank you, that clears things up. I suppose I could initially launch the app with the webdriver and then manipulate it using WebDriver UDF. Also assuming the webdriver instance is just a normal window I can normally manipulate with normal mouse/finger actions and standard AutoIt functions. I think that might work... I'll give it a shot.
  14. "How was the browser originally launched?" Quick Answer: Browser originally launched manually (i.e. by opening with mouse) Long Answer: The app (trivia game) I built in PHP/javaScript and I launch and play it on a local network (WAMP). When using a tablet to control the game it's impossible to move the mouse "off screen" to the extended monitor (projector screen) with my finger so since _IEAttach is depreciated I figured I try an implement the WebDriver UDF method in order to be able to click things over on the projector screen. Tried and tried, searched high and low because "_WD_Attach" wasn't 'attaching' so... posted here. yesterday I found this thread "How to attach to an already running Chrome instance?" and Danp2 mentioned, "while you can do this with Firefox, this isn't possible with Chrome." and because I'm using FireFox I went through every page of the WebDriver Help thread but couldn't find anything that solved my issue. Danp2, just to be clear for my understanding, are you saying that the WebDriver UDF does not work with "manually" opened browser windows? In other words It's a utility that creates it's own instances and then is able to manipulate only those 'types' of browser windows? Sure would be nice to 'click' specific elements in a document with an html "id" tag... would have made life easy but if it doesn't work, it doesn't work.
  15. Hello SOLVE-SMART, thank you for taking a look. "refers to gaming related automation" This automation has nothing to do with a commercial game. I am trying to build "automation" so that I can click an AutoIt GUI on my tablet which in turn will click a place on a webpage which is shown on a projector screen. Please see attached image, it should explain a lot. The "game" is a simple self programmed Trivia type game which I use at events, etc. With old IE and "#include <IE.au3>" it was simple to click but things have changed and I need to learn/utilize the WebDriver UDF to get the click but am having difficulties. Basically I'm just trying to "attach" to a currently open widow (the trivia window) and then when clicking a button on the AutoIt GUI it clicks a div in the page that is shown on the projector.
  16. I've spent days on this searching high and low (google / these forums) and running my code over and over but still can't get/grasp this implementation.... so, hoping somebody will help me out. Goal Using the WebDriver UDF, 1.) On click of a button/hotspot of an AutoIt GUI 2.) "Attach" to an EXISTING Window that's already open (not create a new window) 3.) and then Click on an "a" tag (display:block) that wraps a div Other Info The "Existing Window" that is already open will be in a 2nd monitor and or projector screen with varying aspect ratio and or pixel dimensions. Otherwise I would use just basic AutoIt MouseMove / MouseClick functions. I.E. I have no way to know "where" to click and therefore am trying to use the WebDriver UDF Window Info (Using "AutoIt v3 Window Info) The "Title" of the window is: CJ Media Master - Media Selection — Mozilla Firefox URL OFFLINE Site (Running on local WAMP installation) Path (Virtually Hosted) - http://gm_local/app/app_index.php WebDriver UDF Status I have download and properly set up the files. The "wd_demo.au3" runs fine and running some basic code like "_WD_Navigate" I have been able to implement easily. I like using FireFox as it is my preferred browser but willing to change to Chrome or Edge if need be. Issue (see code below) I cannot get "_WD_Attach" to work. From my understanding, "_WD_Attach" is just like "_IEAttach" and it should let me Attach to the specified instance of a Browser window (i.e. the window I have already open) but for the life of me... I can't get it to work > "_WD_Attach ==> No match". YES, I am using FireFox and the window is open. Code Note that the GUI code is not in the code below (to keep it simple). I have no issues creating clicking on the GUI, just the issue with "Attaching" using the WebDriver UDF and clicking using the WebDriver UDF #include <Constants.au3> #include "udf\wd_core.au3" #include "udf\wd_helper.au3" #include "udf\wd_capabilities.au3" Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Global $sCapabilities, $sSession Global $game_window_title = "CJ Media Master" ; the Title of the window Global $website = "http://www.yahoo.com" ; This will open a new window of FireFox. NOT what I want ;ShellExecute("C:\Program Files\Mozilla Firefox\firefox.exe", "--remote-debugging-port=9222") SetupGecko() _WD_Startup() If @error <> $_WD_ERROR_Success Then Exit MsgBox(0, "Error", "Firefox Driver failed to load") $sSession = _WD_CreateSession($sCapabilities) If @error <> $_WD_ERROR_Success Then Exit MsgBox(0, "Error", "Firefox Driver failed to create a session") ;_WD_Navigate($sSession, $website) ; opens a webpage > Works Sleep(1000) ; _IEAttach > old > depricated ;_WD_Attach($sSession, $game_window_title, "title") ; Fail ;_WD_Attach($sSession, $game_window_title) ; Fail $my_game_window = _WD_Attach($sSession, $game_window_title) ; Fail > _WD_Attach ==> No match ; After I get a "match", i.e. a good $my_game_window VAR, I should be able to use ; _WD_GetElementById to "Click" the DIV with _WD_ElementAction($sSession, $will_click_this, 'click') Func SetupGecko() ; Have no idea why or which "Port" to use or if even this _WD_Option is needed but... the uncommented one below seems to work. _WD_Option('Driver', 'udf\geckodriver.exe') Local $iPort = _WD_GetFreePort(4444, 4500) ; instead of specifing a specific port, this function will find a free port from one of the ports listed _WD_Option('Port', $iPort) ;_WD_Option('Port', 9515) ;_WD_Option('Port', 4444) ;If @error Then Return SetError(@error, @extended, 0) ;_WD_Option('Port', $iPort) ;_WD_Option('DriverParams', '--port=' & $iPort & ' --log trace') ; WebDriver Capabilities ; See: https://www.autoitscript.com/wiki/WebDriver_Capabilities _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'firefox') _WD_CapabilitiesAdd('browserName', 'firefox') _WD_CapabilitiesAdd('acceptInsecureCerts', True) ;_WD_CapabilitiesAdd('debuggerAddress', 9222) ;_WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing in this demo $sCapabilities = _WD_CapabilitiesGet() ; Doesn't work ;$sCapabilities = '{"capabilities":{"alwaysMatch":{"acceptInsecureCerts":true, "pageLoadStrategy":"none", "moz:firefoxOptions": {"args": ["-kiosk", "-private", "-profile", "C:\\Users\\Username\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\Profile.Name"]}}}}' Return $sCapabilities EndFunc ; SetupGecko ;_WD_DeleteSession($sSession) ;_WD_ShutDown()
×
×
  • Create New...