Jump to content

Recommended Posts

Posted

@mLipok Instead of zooming in on Chrome, could you resize the window larger than the screen to mimic the zoom?

Why are you zooming in the first place? If it's for the user's preferences, you could zoom in when they need to take some action, and zoom back out when you need to automate actions.

(And yes, I realize these are both workarounds, but I like to ignore the underlying issues as they're generally not going to be quickly fixed :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
Posted (edited)

Thanks for both answers.

Here I found confirmation.
https://bugs.chromium.org/p/chromedriver/issues/detail?id=628

  Quote
Comment 23 by chern...@gmail.com on Thu, Apr 8, 2021, 5:22 PM GMT+2
Issue is still reproducing. 89.0.774.54 driver version
Expand  


As to :

  On 11/28/2021 at 1:25 PM, Danp2 said:

You may want to review the following discussion --

Expand  

I will look deeply in next few days.

 

As to @seadoggie01 question: 

  On 11/28/2021 at 2:28 PM, seadoggie01 said:

Why are you zooming in the first place?

Expand  

I have no intention to use this, it just happend when I work on my project, then the settings was saved in the chrome profile ( used by my project), and when I want to continue with further tests, all the things that worked a moment ago stopped working unexpectedly.

So the question is how to prevent them?

The best way would be to set zoom to 100% each time my scritps run new instance via WebDriver.

But how to do that ? I mean how to change zoom settings in each specyfic browser using WebDriver or even using other tricks (i.e. RegistryEdit) ?

btw.
I want to do without sending the keys to the window.

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

I already saw that there is specific setting for IE:
 

https://www.software-testing-tutorials-automation.com/2015/07/iedriver-how-to-resolve-set-ie-browser.html

  Quote
// Set desired capabilities to Ignore IEDriver zoom level settings and disable native events.
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability("EnableNativeEvents", false);
caps.setCapability("ignoreZoomSetting", true);
Expand  

but as so far I do not find any common solutions, or even specific solutions for other browsers.

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)

is this:
https://webdriver.io/docs/api/jsonwp/#sendkeys

common for each browsers ?
How to use "sendkeys" with WD UDF ?

because it could be the solutions.

Example from here:
https://www.software-testing-tutorials-automation.com/2015/07/iedriver-how-to-resolve-set-ie-browser.html

  Quote

  // Press CTRL + 0 keys of keyboard to set IEDriver Instance zoom level to 100%.
  driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, "0"));
Expand  


I was also looking here:
https://www.w3.org/TR/webdriver/#dfn-element-send-keys


But for my current understanding of WebDriver and WD UDF.....  this is too complicated.... need time to increase my knowledge, and in the meantime any help will be appreciated.

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 11/28/2021 at 3:38 PM, mLipok said:
Expand  

AFAIK, this is outdated methodology that was replaced by current W3C webdriver implementation

  Quote
Expand  

This is implemented in _WD_ElementAction / 'value'.

You can use _WD_Action / 'actions' to send keystrokes directly to the main browser window. There are some existing examples on the forum.

Posted (edited)
  On 11/28/2021 at 3:24 PM, mLipok said:

But how to do that ? I mean how to change zoom settings in each specyfic browser using WebDriver or even using other tricks (i.e. RegistryEdit) ?

Expand  

Without sending keys, one possible workaround (tested on Chrome only)
 

_WD_ExecuteScript($sSession, "document.body.style.zoom='100%';void(0);")

This will only set the current doc zoom, if you navigate to another page or refresh the current website, it will change again to the chrome browser default zoom.

Edited by MarvKLM
Posted

I'm not asking about zooming document, but browser, and if you check then you notice that this are 2 different things.

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

  • Danp2 changed the title to WebDriver UDF (W3C compliant version) - 12/03/2021
Posted (edited)

I have some issue with few pages.

For example in this following repro script:

#include "wd_helper.au3"
#include "wd_capabilities.au3"

_Example()

Func _Example()
    Local $WD_SESSION = _MY__WD_SetupChrome(False)
    _WD_Navigate($WD_SESSION, 'https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/platform/runtime_enabled_features.json5?q=runtime_enabled_features.json5&ss=chromium')
EndFunc   ;==>_Example

Func _MY__WD_SetupChrome($b_Headless, $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)

    If $s_Log_FileFullPath = Default Then
        Local $s_Default_Log_File = @ScriptDir & '\Log\' & @YEAR & @MON & @MDAY & '-' & @HOUR & @MIN & @SEC & ' Chrome - WebDriver - Testing.log'
        _WD_Option('DriverParams', '--log-path=' & '"' & $s_Default_Log_File & '"')
    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', 'start-maximized')
    _WD_CapabilitiesAdd('args', 'disable-infobars')
    _WD_CapabilitiesAdd('args', 'user-data-dir', 'C:\Users\' & @UserName & '\AppData\Local\Google\Chrome\User Data\Default')
    _WD_CapabilitiesAdd('args', '--profile-directory', Default)
    _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
    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)
    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


The requested URL https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/platform/runtime_enabled_features.json5?q=runtime_enabled_features.json5&ss=chromium

should open "runtime_enabled_features.json5" features list.
But my repro code doesn't display them well.

As so far I think that some of capabilties should be or should'nt be used.


Any body could help in solving this problem ?

 

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

I would like to request adding the `binary` options to the vendor-specific options (similar to `w3c`), it can be used to set the path of the binary executable in Chrome Driver like so:

_WD_CapabilitiesAdd('binary', 'C:\Software\Chromium\bin\chrome.exe')

 

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Posted (edited)
  On 12/7/2021 at 2:18 AM, Danp2 said:

I could have sworn that this was working in an earlier revision.

Expand  

No.
It was only as TODO in advanced example:

#TODO check how to use 'binary'
# _WD_Capabilities_Add('binary', 'c:\Program Files (x86)\Mozilla Firefox\firefox.exe')

already added in:
https://github.com/Danp2/WebDriver/pull/104

 

take a look also on Wiki:   https://www.autoitscript.com/wiki/WebDriver#Creating_Capabilities_string

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

If somebody need to add any capability that are not showed in this following example:
https://www.autoitscript.com/wiki/WebDriver#Creating_Capabilities_string

Please provide here (on the forum in this particular thread or its future continuation)  name of capability which you want to use, and link to reference documentation for this capability usage.


Then I check if this is possible to use the requested capability with wd_capabilities.au3 UDF and I will suplement the Advanced Example in the Wiki and if it will be need I will update this UDF in order to provide support for such capability.

 

Regards,
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)

in some of my script I had to add:

_WD_CapabilitiesAdd('args', 'user-agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36')

I do not know from where I get this following settings (find somwhere on the internet):

  Quote

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36

Expand  

And this was my previous usage, which lead me to some other issues.
When I change to:

  Quote

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36

Expand  

Everything started working fine. At least I hope so.
I hesitate and I worry because I don't know if this form:

  Quote

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36

Expand  

Is correct or not ?

btw.
How do you usually construct this settings/string ?

EDIT 1:
I see I should'nt use:

  Quote

(X11; Linux x86_64)

Expand  

But do not know the right contruction rules.
Here:
https://stackoverflow.com/a/62491863/5314940

I found this:

return navigator.userAgent;

and:

  Quote

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.53 Safari/537.36
Expand  

I was trying to use this JavaScript in GoogleChrome console but I get: 

  Quote

Uncaught SyntaxError: Illegal return statement

Expand  

Do you know how to check current userAgent in console ?

Also here:
https://www.codegrepper.com/code-examples/javascript/get+user+agent+javascript

I found some other userAgent example settings.

EDIT 2:
Reference documentation:
https://wicg.github.io/ua-client-hints/#user-agent

EDIT 3:
Finally for this moment I stick with this solution:

_WD_CapabilitiesAdd('args', 'user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36')

But if somebody have better solutions, then any comments are welcome.

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 12/8/2021 at 8:44 AM, mLipok said:

How do you usually construct this settings/string ?

Expand  

As far as I know there isn't any standard, it's basically bits from the old browsers with the version numbers changed.

Wikipedia has good information about it: https://en.m.wikipedia.org/wiki/User_agent

I just extract the whole string from a retail Chrome build and use it in my automation :)

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Posted (edited)

After some further testing for this moment i use:

_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')

 

EDIT:
Advanced Example already suplemented
https://www.autoitscript.com/wiki/WebDriver#Creating_Capabilities_string

 

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)
_WD_FindElement($sSession, $sStrategy, $sSelector, $sStartElement = Default, $lMultiple = Default)

in wd_Demo ,Find examples as follows:

$aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div/input", Default, True)

Here the  $sStartElement parameter is 'Default = ""'.

I never quite understand what the use of this $sStartElement  parameter is there.

Is there any example of 'Default <> ""'?

Thanks in advance!

 

Edited by Letraindusoir
Posted (edited)
  On 12/9/2021 at 5:14 PM, Letraindusoir said:

Is there any example of 'Default <> ""'?

Expand  

yes in the middle of wd_core.au3 UDF

If $sStartNodeID = Default Then $sStartNodeID = ""

And this mean:

Local $sElement_Form = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//form') ;; start looking for "form" element from the root element of the document
Local $sElement_Input = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//input', $sElement_Form) ;; start looking for "input" element from $sElement_Form

 

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

Thanks to @water on the Wiki we have new page:

https://www.autoitscript.com/wiki/WebDriver_Capabilities


 

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

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

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