Langmeister Posted July 14, 2020 Share Posted July 14, 2020 (edited) Hi, I'm sure that this is a simple question regarding webdriver udf but my search on the forum did not result in the exact same scenario that I need. I will adapt it to my corporate needs but at first I want it to work with an example everybody can reproduce if needed. I navigate to https://www.daysoftheyear.com/ and want to find out what special day today is. Using the following Code returns the wanted text that today is 'shark awareness day' in the console but it is not pasted in notepad as it is not copied as it probably should be. #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession, $sID _WD_Option("Driver", "C:\Program Files (x86)\AutoIt3\chromedriver.exe") _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.daysoftheyear.com/?timezone_offset=nan") _WD_LoadWait($sSession) Sleep(3000) Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div[2]/header/div/div[1]/div/div[2]/h3/a") _WD_ElementAction($sSession, $sElement, 'text') ClipGet() Run("notepad.exe") Sleep(500) Send("^v") Scite returns this, therefore the text has been found but the last mile to paste it to notepad or excel does not work for me. __WD_Get: URL=HTTP://127.0.0.1:9515/session/b72166b774d7fefb258b3721fc1d4306/element/657e6b5d-31a9-46a8-85c4-acb7f72bf659/text __WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"Shark Awareness Day"}... _WD_ElementAction: {"value":"Shark Awareness Day"}... Thanks in advance! Edited July 14, 2020 by Langmeister Issue solved Link to comment Share on other sites More sharing options...
pseakins Posted July 14, 2020 Share Posted July 14, 2020 I have no experience with the functions you are trying to use here but I can see that you have not pushed anything into the clipboard buffer for ClipGet() to retrieve. From what i can see you should probably use ClipPut($sResponseText) after it has been filled. Phil Seakins Link to comment Share on other sites More sharing options...
Nine Posted July 14, 2020 Share Posted July 14, 2020 Here a another (better ?) way than copy/paste : #include "..\WebDriver\wd_core.au3" #include "..\WebDriver\wd_helper.au3" Local $sDesiredCapabilities, $sSession, $sID _WD_Option("Driver", "..\WebDriver\chromedriver.exe") _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.daysoftheyear.com/?timezone_offset=nan") _WD_LoadWait($sSession) Sleep(3000) Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div[2]/header/div/div[1]/div/div[2]/h3/a") $sText = _WD_ElementAction($sSession, $sElement, 'text') Run("notepad.exe") Local $hWnd = WinWaitActive ("[CLASS:Notepad]") Local $hCtrl = ControlGetHandle ($hWnd, "", "Edit1") ControlSetText ($hWnd, "", $hCtrl, $sText) Langmeister 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Langmeister Posted July 14, 2020 Author Share Posted July 14, 2020 Does exactly what I was searching for, thanks a lot! Thanks for your efforts too @pseakins 11 minutes ago, Nine said: Here a another (better ?) way than copy/paste : #include "..\WebDriver\wd_core.au3" #include "..\WebDriver\wd_helper.au3" Local $sDesiredCapabilities, $sSession, $sID _WD_Option("Driver", "..\WebDriver\chromedriver.exe") _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.daysoftheyear.com/?timezone_offset=nan") _WD_LoadWait($sSession) Sleep(3000) Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div[2]/header/div/div[1]/div/div[2]/h3/a") $sText = _WD_ElementAction($sSession, $sElement, 'text') Run("notepad.exe") Local $hWnd = WinWaitActive ("[CLASS:Notepad]") Local $hCtrl = ControlGetHandle ($hWnd, "", "Edit1") ControlSetText ($hWnd, "", $hCtrl, $sText) 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