Jump to content

Recommended Posts

Posted
  On 3/21/2022 at 5:31 PM, Danp2 said:

@sylremoHave you tried using multiple sessions with a single instance of Chromedriver?

Expand  

I did try to create 2 session with a single chromedriver instance but when creating 2nd session, calling _WD_CreateSession didnt return anything although it did open a new chrome window.

Posted

Howdy,

how can I access the parent node of a selected node and additional with a negotation condition in XPath?

My example doesn't work because it's not a valid Syntax, I guess I'm using the ".." and "not()" wrong 🤦‍♂️

_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//p['Place bet']..button[not(@disabled)]")


The pointed Element is what I want to find (NOTE: class & dashlane-rid attribute get always random generated values, not useable)
image.thumb.png.4b0ad31a4f233211005a4d1e0b8d08ca.png

Posted

If somebody is interested in here is the solution how to use parent axis "::" and negation "not()"
 

_WD_FindElement($mySession, $_WD_LOCATOR_ByXPath, "//p[text()='Place bet']/parent::button[not(@disabled)][@color='green']")

Google is still my best friend 😄

  • Danp2 changed the title to WebDriver UDF (W3C compliant version) - 03/28/2022
Posted

Latest update just released. See below for change log.

  Quote

## [0.8.0] - 2022-03-28

### Added

- _WD_Option: Support for "ConsoleSuffix", "ErrorMsgbox", "OutputDebug", and "Version" options
- _WD_ElementSelectAction: Added Multiselect functionality

### Changed

- __WD_ConsoleWrite: Utilize new ConsoleSuffix setting
- __WD_Error: Refactored for improved functionality
- _WD_CapabilitiesDump: Adhere to debug level settings
- _WD_Startup: Additional logging when error detected

### Fixed

- _WD_Startup: Display of webdriver bit level (32 / 64)
- _WD_UpdateDriver: Set @extended correctly
- _WD_GetBrowserVersion: Binary type checking
- _WD_Cookies: Deletion corrected
- wd_capabilities: Validate initialization result
- wd_demo: Updated routines to ensure proper functionality

### Project

- Scripts should use _WD_LastHTTPResult() to obtain the result of the most recent HTTP request as Webdriver functions no longer set @extended to last HTTP request result.
- Improved logging / error reporting by making sure that functions call __WD_Error.

Expand  

 

Posted

I am using _WD_PrintToPdf and trying to make the created PDF just one whole page containing everything,  I checked https://www.w3.org/TR/webdriver/#print-page and tried with page width and height, scale and shrinkToFit but not working well for me

;~      $pdfPrint = _WD_PrintToPdf($sSession,'{"scale":0.5}')
;~      $pdfPrint = _WD_PrintToPdf($sSession, '{"shrinkToFit":false}')
;~      $pdfPrint = _WD_PrintToPdf($sSession, '{"orientation":"landscape"}')
        $pdfPrint = _WD_PrintToPdf($sSession, '{"page": { "width": 1000, "height": 2000}}')
;~      $pdfPrint = _WD_PrintToPdf($sSession)

Is there such a parameter as pagesize? And can i set it to just fit the whole result in one page?

Posted
  On 3/28/2022 at 6:46 PM, Moonscarlet said:

 

;~      $pdfPrint = _WD_PrintToPdf($sSession,'{"scale":0.5}')
;~      $pdfPrint = _WD_PrintToPdf($sSession, '{"shrinkToFit":false}')
;~      $pdfPrint = _WD_PrintToPdf($sSession, '{"orientation":"landscape"}')
        $pdfPrint = _WD_PrintToPdf($sSession, '{"page": { "width": 1000, "height": 2000}}')
;~      $pdfPrint = _WD_PrintToPdf($sSession)

And can i set it to just fit the whole result in one page?

Expand  

I answer in next few hour when I come to my laptop.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 3/28/2022 at 6:46 PM, Moonscarlet said:

Is there such a parameter as pagesize? And can i set it to just fit the whole result in one page?

Expand  

you are lucky, that I solve this mystery few month ago....

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

btw.

in wd_demo.au3 there is DemoPrint()

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

@mLipokthanks, however, i am still facing the same problem, for example see this link

https://www.lumex.com/lcd-displays-character-20x2+20x4.html

  Reveal hidden contents

 

using no options

$pdfPrint = _WD_PrintToPdf($sSession)

I got this pdf (which is divided into more pages and that "column" on the right was pushed below when it's supposed to be at the top right:

  Reveal hidden contents

 

I tried the options you listed and got the same result:

$pdfPrint = _WD_PrintToPdf($sSession, '{"page":{"width":29.70,"height":42.00},"margin":{"top":2,"bottom":2,"left":2,"right":2},"scale":0.5,"orientation":"landscape","shrinkToFit":true,"background":true,"pageRanges":[1,"1-1"]}')

 

  Reveal hidden contents

 

However, trying to print to pdf manually in the browser (CTRL+P) gives me:

  Reveal hidden contents

 

So, I am not really sure how to get it like that using the udf ;S

Maybe paper size? but i don't know how that would be possible

image.png.1777e82d257429f35bffa0e094dc9999.png

Posted (edited)

Try to use:

#AutoIt3Wrapper_UseX64=N
#include "wd_helper.au3"
#include "wd_capabilities.au3"

_Example_2()

Func _Example_2()
;~  Local $sSession = _MY__WD_SetupFireFox(False)
    Local $sSession = _MY__WD_SetupChrome(True)
    If @error Then Return SetError(@error, @extended)

    _WD_Navigate($sSession, "https://www.lumex.com/lcd-displays-character-20x2+20x4.html")
    If @error Then
        _WD_Shutdown()
        Return
    EndIf

    ; https://www.w3.org/TR/webdriver/#print-page
    ; https://stackoverflow.com/a/68353518/5314940
    ; http://www.polger.wroclaw.pl/Formaty-papieru,51.html

    Local $s_JSON_PrintOptions = StringReplace( _ ; TABLOID 279.4 x 431.8 = https://www.engineeringtoolbox.com/office-paper-sizes-d_213.html
            '{' & _
            '   "page":{' & _
            '           "width": 27.94' & _
            '           ,"height": 43.18' & _
            '       }' & _
            '   ,"margin":{' & _
            '           "top": 0' & _
            '           ,"bottom": 0' & _
            '           ,"left": 0' & _
            '           ,"right": 0' & _
            '       }' & _
            '   ,"scale": 1.0' & _
            '   ,"orientation":"portrait"' & _
            '   ,"background": true' & _
            '   ,"pageRanges": ["1-10"]' & _
            '}', @TAB, '')


    Local $sFileFullPath = @ScriptDir & '\PackingSlip_1_A3.pdf'
    _Test($sSession, $s_JSON_PrintOptions, $sFileFullPath)
    _WD_Shutdown()
EndFunc   ;==>_Example_2

Func _Test($sSession, $sOptions, $sFileFullPath)
    Local $dBinaryDataToWrite = _WD_PrintToPdf($sSession, $sOptions)
    Local $hFile = FileOpen($sFileFullPath, $FO_OVERWRITE + $FO_BINARY)
    FileWrite($hFile, $dBinaryDataToWrite)
    FileClose($hFile)

    ShellExecute($sFileFullPath)
EndFunc   ;==>_Test

Func _MY__WD_SetupChrome($b_Headless = False, $s_Download_dir = '', $_WD_DEBUG_LEVEL = Default, $s_Log_FileFullPath = Null)
    If $_WD_DEBUG_LEVEL = Default Then
        $_WD_DEBUG = $_WD_DEBUG_Error
        If Not @Compiled Then $_WD_DEBUG = $_WD_DEBUG_Info
    EndIf

    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DefaultTimeout', 1000)

    _WD_UpdateDriver('chrome')
    If @error Then Return SetError(@error, @extended, '')

    #  !!! WARRNING !!!   AS DEFAULT DO NOT USE '--log-path=' BECAUSE OF   GDPR / RODO law rules
    If $s_Log_FileFullPath = Default Then
        Local $s_Default_Log_File = @ScriptDir & '\Log\' & @YEAR & @MON & @MDAY & '-' & @HOUR & @MIN & @SEC & ' WebDriver - Chrome - Testing.log'
        _WD_Option('DriverParams', '--log-path=' & '"' & $s_Default_Log_File & '"')
    ElseIf IsString($s_Log_FileFullPath) And StringLen($s_Log_FileFullPath) Then
        _WD_Option('DriverParams', '--log-path=' & '"' & $s_Log_FileFullPath & '"')
    EndIf

    _WD_CapabilitiesStartup()
    _WD_CapabilitiesAdd('alwaysMatch')
    _WD_CapabilitiesAdd('acceptInsecureCerts', True)

    _WD_CapabilitiesAdd('firstMatch', 'chrome')
    _WD_CapabilitiesAdd('browserName', 'chrome')
    _WD_CapabilitiesAdd('w3c', True)
    _WD_CapabilitiesAdd('args', 'user-data-dir', 'C:\Users\' & @UserName & '\AppData\Local\Google\Chrome\User Data\Default')
    _WD_CapabilitiesAdd('args', 'user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win' & StringReplace(@OSArch, 'X', '') & '; ' & @CPUArch & ') AppleWebKit/537.36 (KHTML, like Gecko) Chrome/' & _WD_GetBrowserVersion('chrome') & ' Safari/537.36')
    _WD_CapabilitiesAdd('args', '--profile-directory', Default)
    _WD_CapabilitiesAdd('args', 'start-maximized')
    _WD_CapabilitiesAdd('args', 'disable-infobars')
    _WD_CapabilitiesAdd('args', '--no-sandbox')
    _WD_CapabilitiesAdd('args', '--disable-blink-features=AutomationControlled')
    _WD_CapabilitiesAdd('args', '--disable-web-security')
    _WD_CapabilitiesAdd('args', '--allow-running-insecure-content') ; https://stackoverflow.com/a/60409220
    _WD_CapabilitiesAdd('args', '--ignore-certificate-errors') ; https://stackoverflow.com/a/60409220
    _WD_CapabilitiesAdd('prefs', 'credentials_enable_service', False) ; https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-12272021/?do=findComment&comment=1464829
    If $b_Headless Then _
            _WD_CapabilitiesAdd('args', '--headless')
    If $s_Download_dir Then _
            _WD_CapabilitiesAdd('prefs', 'download.default_directory', $s_Download_dir)
    _WD_CapabilitiesAdd('excludeSwitches', 'disable-popup-blocking') ; https://help.applitools.com/hc/en-us/articles/360007189411--Chrome-is-being-controlled-by-automated-test-software-notification
    _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation')
    _WD_CapabilitiesAdd('excludeSwitches', 'load-extension')

    _WD_CapabilitiesDump(@ScriptLineNumber & ':WebDriver: testing')
    Local $s_Capabilities = _WD_CapabilitiesGet()

    _WD_Startup()
    If @error Then Return SetError(@error, @extended)

    Local $WD_SESSION = _WD_CreateSession($s_Capabilities)
    Return SetError(@error, @extended, $WD_SESSION)

EndFunc   ;==>_MY__WD_SetupChrome

Func _MY__WD_SetupFireFox($b_Headless, $s_Download_dir = '', $_WD_DEBUG_LEVEL = Default, $s_Log_FileFullPath = Null)
    If $s_Download_dir Then $s_Download_dir = StringReplace($s_Download_dir, '\', '\\')

    If $_WD_DEBUG_LEVEL = Default Then
        $_WD_DEBUG = $_WD_DEBUG_Error
        If Not @Compiled Then $_WD_DEBUG = $_WD_DEBUG_Info
    EndIf

    #  !!! WARRNING !!!   AS DEFAULT DO NOT USE '--log-path=' BECAUSE OF   GDPR / RODO law rules
    If $s_Log_FileFullPath = Default Then
        Local $s_Default_Log_File = @ScriptDir & '\Log\' & @YEAR & @MON & @MDAY & '-' & @HOUR & @MIN & @SEC & ' WebDriver - FireFox - Testing.log'
        _WD_Option('DriverParams', '--log-path=' & '"' & $s_Default_Log_File & '"')
    ElseIf IsString($s_Log_FileFullPath) And StringLen($s_Log_FileFullPath) Then
        _WD_Option('DriverParams', '--log-path=' & '"' & $s_Log_FileFullPath & '"')
    EndIf
    _WD_Option('Driver', 'geckodriver.exe')
;~  _WD_Option('DriverParams', '--log trace --marionette-port 2828')
    _WD_Option('Port', 4444)
    _WD_Option('DefaultTimeout', 1000)

    _WD_Startup()
    If @error Then Return SetError(@error, @extended, '')

    _WD_CapabilitiesStartup()
    _WD_CapabilitiesAdd('alwaysMatch')
    _WD_CapabilitiesAdd('acceptInsecureCerts', True)
    _WD_CapabilitiesAdd('firstMatch', 'firefox')
;~  _WD_CapabilitiesAdd('args', '-profile')
;~  _WD_CapabilitiesAdd('args', @LocalAppDataDir & '\Mozilla\Firefox\Profiles\WD_Testing_Profile') ; CHANGE TO PROPER DIRECTORY PATH

    If $b_Headless Then _
            _WD_CapabilitiesAdd('args', '--headless')

    _WD_CapabilitiesDump(@ScriptLineNumber & ':WebDriver')
    Local $s_Capabilities = _WD_CapabilitiesGet()

    _WD_Startup()
    If @error Then Return SetError(@error, @extended)

    Local $WD_SESSION = _WD_CreateSession($s_Capabilities)
    Return SetError(@error, @extended, $WD_SESSION)

    Return SetError(@error, @extended, $WD_SESSION)
EndFunc   ;==>_MY__WD_SetupFireFox

 

switch between:
 

;~  Local $sSession = _MY__WD_SetupFireFox(False)
    Local $sSession = _MY__WD_SetupChrome(True)

It is issue with "chromedriver.exe"

https://bugs.chromium.org/p/chromium/issues/detail?id=1311166

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

Hi,

I’m beginner with webdriver and I execute _WD_Navigate on an intranet url, but this intranet open a popup windows to ask a password key!

I want to handle this popup windows, but at this time the script is stopped because I think _WD_Navigate is waiting an HTTP response

 

 

_WD_Navigate($sSession, "https://opnjhg03-adm.rouen.xxzzz.fr:31943")
        ; >> here the script is stopped !
    if WinExists("Password Required") then; popup windows
        ; I will do somethink to handle the popup windows
    EndIf

 

 

There is an issue to solve this problem

Thanks a lot

FIREFOX Demande Password.jpg

Edited by tac7
Posted (edited)
  On 3/29/2022 at 8:38 AM, tac7 said:

I want to handle this popup windows, but at this time the script is stopped because I think _WD_Navigate is waiting an HTTP response

Expand  

This is normal proper behavior, due to security rules.
And this is not related to WebDriver at all, but it is related to Browser which do not release process till you provide your credentials.

Trying to bypasing this with AutoIt is possible but is not in line with forum rules.
Please do not ask again about how to solve this.

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 3/29/2022 at 9:38 AM, mLipok said:

Trying to bypasing this with AutoIt is possible but is not in line with forum rules.
Please do not ask again about how to solve this.

Expand  

I don't think that this is something we need to avoid, because it's an internal website and they're meant to reach this website normally. If they were to use the existing profile, the password would be properly provided to the website. This doesn't seem to bypass anything and instead implements the recommended security measures :)

Maybe I'm misunderstanding something and if so, please pm me to shut up :D

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

  Reveal hidden contents
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...