Jump to content

Recommended Posts

Posted

It did not work, and I added _WD_GetFrameCount($sSession) which returned 0.

How can I check for frames or iframes inside he html ?  

Posted

Hello!

With this addon I can start Chrome headless (by passing --headless to args in $sDesiredCapabilities).

Is there any way to show the window later on different conditions? Or once it started without the UI, it will not be visible anymore?

Posted
  On 11/22/2020 at 9:29 AM, AttilaP said:

Hello!

With this addon I can start Chrome headless (by passing --headless to args in $sDesiredCapabilities).

Is there any way to show the window later on different conditions? Or once it started without the UI, it will not be visible anymore?

Expand  

I guess you can do that by using WInsetState, but you have to get the handle of the windows first.

Posted

I installed it and the result is the same. I tried the element by id, by class, by name .... but with no success in clicking the button, or reading the ui.

If I get the position of the element, can I send a mouse click to the location ? because the ui dialog is placed middle no matter of my scroll.

and I want to be headless, so MouseCLick() is not an option for me, I want the webdriver to the clicking. 

Posted

@Siwa The link you sent me via PM won't load for me. Not sure why... maybe limited access geographically. <shrug>

Maybe this will help you --

#include <wd_core.au3>

Local $sDesiredCapabilities

SetupChrome()
_WD_Startup()

Local $sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://cdn.rawgit.com/salmanarshad2000/demos/v1.0.4/jquery-ui-dialog/modal-dialog-with-buttons.html")

Local $oElement1 = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//div[@class='ui-dialog-buttonset']/button[1]")
Local $oElement2 = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//div[@class='ui-dialog-buttonset']/button[2]")

_WD_ElementAction($sSession, $oElement1, 'click')


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": {"w3c": true, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}}'
EndFunc

 

Posted (edited)

It did not work, and this is the console :

 

  Reveal hidden contents

Edit :

Finally I got it working by :

_WD_ExecuteScript($sSession,"document.getElementById('j_idt250').click();")

Glad to solve it finally, and learned how to use JS scripts the right way 😉

(I guess it will be a huge step forward for new learners like me, if you could include this as a example in your demo )

Edited by Siwa
Posted

@Siwa Not sure why the javascript worked where the standard click didn't, but glad you found a solution. FWIW, the control is being found successfully, but the click attempt is failing with "element not interactable". From the webdriver specs --

  Quote
Error Code HTTP Status JSON Error Code Description
element not interactable 400 element not interactable A command could not be completed because the element is not pointer- or keyboard interactable.
Expand  

 

Posted

Hi!

I am pretty new to this UDF and I try to fill a login form with it, using ChromeDriver. However, it always replace the @ sign in the username to the text what I have on my clipboard.

ChromeDriver 86.0.4240.22

AutoIt 3.3.14.5

A minimalistic code to reproduce this behavior:

#include "wd_core.au3"
#include "wd_helper.au3"

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

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}}'
_WD_Startup()
If @error <> $_WD_ERROR_Success Then
    Exit -1
EndIf

$sSession = _WD_CreateSession($sDesiredCapabilities)

$username = "user@test.com"
_WD_Navigate($sSession, "https://www.w3schools.com/html/html_forms.asp")
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//input[@id="fname"]');
_WD_ElementAction($sSession, $sElement, 'value', $username);
Sleep(15000)
_WD_DeleteSession($sSession)
_WD_Shutdown()
Exit

 

First I copied the text 'CLIPBOARD' to the clipboard with Ctrl+C, then run the above - the result is attached.

I see the following in the chrome.log:

[1606145142.741][INFO]: Cannot switch to US keyboard layout - some keys may be interpreted incorrectly

And below the following, after the letter 'r' in user:
 

  Reveal hidden contents

For me it seems it tries to write the @ sign with sending 17, 18 down, then v, finally 17, 18 up. Which is Alt + Ctrl  + v I assume, and that should be correct, that's how I write it on my hungarian keyboard. Nevertheless it is interpreted as simple Ctrl + V.

Is there any other method I can use? Also, what shall I do if I want to overwrite the actual form element? Like in the example, I do not want to keep the text John there.

Thank you in advance!

Képernyőkép 2020-11-23 161809.png

Posted

Thanks Danp2, I installed the US language pack which solved the problem.

Now I face an another one: I try to download a file from a URL which is not a direct link to the file. I tried to use _WD_DownloadFile but that saved the HTML source instead. When I check the request in the browser, I see that the response header has this:

content-disposition: attachment;filename="=?ISO-8859-1?Q?=D6n=E9letrajz.pdf?="
content-length: 36855
content-type: application/pdf;charset=UTF-8

And the file is downloaded.

I can not find a link to mimic this behavior, unfortunately. Is there any way to grab these files and save them into a specific folder? I found this, but could not get it working.

Related part (Python source):

def enable_download_headless(browser,download_dir):
    browser.command_executor._commands["send_command"] = ("POST", '/session/$sessionId/chromium/send_command')
    params = {'cmd':'Page.setDownloadBehavior', 'params': {'behavior': 'allow', 'downloadPath': download_dir}}
    browser.execute("send_command", params)
 
 

 

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

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