Jump to content

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


Danp2
 Share

Recommended Posts

Dear  @Danp2

i have this page already opened in chrome browser.

i tried to to attached with it by using

_WD_Attach(_WD_Attach($sSession, "Amadeus Retailing Platform - PRD(PRODUCTION) - Google Chrome", Default),

my problem how getting   "$sSession " ID

 

Thanks in advance

Untitled.png

Link to comment
Share on other sites

Dear  @Danp2

i have spend 6 hours trying to solve it 

still open new web page 

I am not very expert so i need your help please.

 

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>

Local $sDesiredCapabilities, $sSession

;ShellExecute("chrome.exe", "--remote-debugging-port=9222")

SetupChrome()
_WD_Startup()

$sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_Navigate($sSession, "HTTP://intranet.airlineretailing.amadeus.com:55001/1ASIHGAPSV/signin/index.html?TXT=Retailing%20Platform&URL=/1ASIHGAPSV/arp/index.html")

Func SetupChrome()

_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"debuggerAddress": "localhost:9222"}}}}'
EndFunc

-------------------------------------------------------------------------------------------------------------------------------------------
>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\11003813\Desktop\AutoIT\xxxx.au3" /UserParams    
+>14:01:25 Starting AutoIt3Wrapper v.16.612.1119.0 SciTE v.3.6.6.0   Keyboard:00000409  OS:WIN_81/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper
>Running AU3Check (3.3.14.2)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\11003813\Desktop\AutoIT\xxxx.au3
+>14:01:25 AU3Check ended.rc:0
>Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\11003813\Desktop\AutoIT\xxxx.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
_WD_IsLatestRelease: True
_WD_IsLatestRelease ==> Success
_WDStartup: OS: WIN_81 WIN32_NT 9600 
_WDStartup: AutoIt: 3.3.14.2
_WDStartup: WD.au3: 0.3.1.0 (Up to date)
_WDStartup: WinHTTP:    1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)
_WDStartup: Driver: chromedriver.exe
_WDStartup: Params: --verbose --log-path="C:\Users\11003813\Desktop\AutoIT\chrome.log"
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"debuggerAddress": "localhost:9222"}}}}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_CreateSession: WinHTTP request timed out before Webdriver
_WD_CreateSession ==> Webdriver Exception: HTTP status = 0
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; $sData={"url":"HTTP://intranet.airlineretailing.amadeus.com:55001/1ASIHGAPSV/signin/index.html?TXT=Retailing%20Platform&URL=/1ASIHGAPSV/arp/index.html"}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_Navigate: WinHTTP request timed out before Webdriver
_WD_Navigate ==> Send / Recv error: HTTP status = 0

 

Thanks in advance

Link to comment
Share on other sites

2 hours ago, samibb said:

_WDStartup: WinHTTP:    1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)

This information is here for a reason. Follow the directions if you want the UDF to work correctly. See my earlier reply if you still don't understand.

Also, you need to explain in detail how the existing Chrome instance was launched. Be specific and be sure to show us that you used the --remote-debugging-port parameter.

Note -- You can use telnet to test if the port is open. From the command line, enter

telnet localhost 9222

If you get the following response, then the port isn't open

Connecting To localhost...Could not open connection to the host, on port 9222: Connect failed

 

Link to comment
Share on other sites

Thanks @Danp2. I tried that before asking but it doesn't return a value:

 

#include <Constants.au3>
#include "wd_core.au3"
#include "wd_helper.au3"
HotKeySet ( "{F2}",  "_XpathMouseElem" )
HotKeySet ( "{F10}",  "_Exit" )
$_WD_DEBUG = $_WD_DEBUG_None ; to hide ChromeDriver console

Local $sDesiredCapabilities = SetupChrome()
_WD_Startup()
Sleep(2000)
_WD_ConsoleVisible()
Local $sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_Navigate($sSession, "http://www.google.com")

Do
  Sleep (50)
Until False

Func _Exit()
   _WD_DeleteSession($sSession)
   _WD_Shutdown()
   Exit
EndFunc

Func SetupChrome()
  _WD_Option('Driver', 'chromedriver.exe')
  _WD_Option('Port', 9515)
  _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')
  Return '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}}'
EndFunc   ;==>SetupChrome

Func _XpathMouseElem()
   $mElement = _WD_GetMouseElement($sSession)
   MsgBox($MB_TOPMOST, "Mouse Element Info", $mElement) ;Returns the id of the element under the mouse

;---- Find outer HTML of element under mouse after F2
   $sValue1 = _WD_ElementAction($sSession, $mElement, 'property', 'outerHTML') ; or innerText // was aElement
   MsgBox(0,"Element OuterHTML",$sValue1 )
;---- Find outer HTML of parent
   $sElement = _WD_FindElement($mElement, $_WD_LOCATOR_ByXPath,  '/..', Default, True)
   $sValue2 = _WD_ElementAction($sSession, $sElement, 'property', 'outerHTML') ; or innerText
   MsgBox(0,"Parent OuterHTML",$sValue2 )
EndFunc ;==>_XpathMouseElem

Simply press F2 over an element and you'll see what I mean.

Thanks.

Edited by NassauSky
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...