Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Xeo786 » 03 May 2023, 02:13

Jasonosaj wrote:
02 May 2023, 12:50
Apologies if this is a ridiculous question. I've been slamming my head against the issue and cannot figure it out, even AFTER searching. If the answer is already in this thread, it's my lack of techinical knowhow that is creating the issue. In any event, I have a website and I want to input text in an edit. The following JS works in the console:

Code: Select all

const input = document.querySelector('input[name="cfDisplay"]');
input.addEventListener("keydown", function(event) {
  if (event.keyCode === 13) {
    event.preventDefault();
    input.value = "your text here";
    document.getElementById("myForm").submit();
  }
});
I have tried a variety of approaches and for the life of me cannot get it to work using Rufaydium. I had THOUGHT that the following would work, but no.

Code: Select all

		JS = 
		(
			const input = document.querySelector('input[name="cfDisplay"]')
		
			input.addEventListener("keydown", function(event) {
			if (event.keyCode === 13) {
				event.preventDefault()
				input.value = "your text here"
				document.getElementById("myForm").submit()
			}
			}
		)
		Session.CDP.Evaluate(js)
Can anyone spot what I'm doing wrong? Unfortunately cannot give access to the page in question...
For executing JS ou can just use

Code: Select all

Session.ExecuteSync(JS)
to setting value to some element

Code: Select all

Session.getElementById("myForm").value := "your text"
Session.querySelector('input[name="cfDisplay"]').value := "your text"
and also you can simlulate keystrokes using sendkey no need to use event,

Code: Select all

Session.querySelector('input[name="cfDisplay"]').sendkey("your text")
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

automater
Posts: 20
Joined: 01 Jul 2022, 08:51

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by automater » 23 May 2023, 16:36

I need some help changing the start and end date fields on a page - I got this code to work in the developer console:

Code: Select all

var datePickers = document.querySelectorAll('kat-date-picker');
datePickers[0].value = '04/19/2023'; // Start date
datePickers[1].value = '05/20/2023'; // End date
When I add it to my AHK script like below, it doesn't work:

Code: Select all

datePickers := Page.QuerySelectorAll("kat-date-picker")
datePickers[0].value := "04/20/2023" ; // Start date
datePickers[1].value := "05/21/2023" ; // End date
For reference, below are the elements that I'm targeting:

Start date:

Code: Select all

<kat-date-picker locale="en-US" class="css-jfggi0" autocomplete="off" value="04/22/2023"><span slot="private-light-dom" style="max-width: 0px; max-height: 0px; overflow: hidden;"></span></kat-date-picker>
End date:

Code: Select all

<kat-date-picker locale="en-US" class="css-jfggi0" autocomplete="off" value="05/22/2023"><span slot="private-light-dom" style="max-width: 0px; max-height: 0px; overflow: hidden;"></span></kat-date-picker>
What am I doing wrong?

JerryMaguire
Posts: 16
Joined: 05 Mar 2023, 11:17

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by JerryMaguire » 31 May 2023, 22:20

There is a frame in the web page, how can I query selector the original session content after clicking a link and executing session.back() to return to the previous web page

JerryMaguire
Posts: 16
Joined: 05 Mar 2023, 11:17

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by JerryMaguire » 01 Jun 2023, 01:13

@Xeo786
I use Chrome.capabilities.addArg("--disable-popup-blocking"), no effect

Manual execution of Chrome can normally prevent pop-up windows, and webdriver manually executes the profile using the same path

Do you know why?

Jasonosaj
Posts: 46
Joined: 02 Feb 2022, 15:02
Location: California

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Jasonosaj » 01 Jun 2023, 13:05

I am trying to get around using FindText to identify the location of a dropdown menu element that requires physical interaction before I am able to get text sent (using send command, not Rufaydium; I can't get Rufaydium to work due my lack of understanding as to all of the elements that need to be changed for the changes to have any effect on the form).
I am able to get the X & Y coordinates of the element using the following code:

Code: Select all

myElement := session.querySelector("select[name='billingCodeSelectList']")
myElement_Location := myElement.rect()
for k, v in myElement_Location
{
    if (k == "x")
        varX := v
    If (k == "y")
        varY := v
}  
These coordinates are accurate relative to the frame, but not with regard to the window or screen. The goal is to have a script that clicks the element and then sends a text string, regardless of the resolution, color palette (e.g., night light active), etc. Can anyone come up with a way to determine the position of varX and varY relative to either the screen or window (i.e., inclusive of the tab bar, address bar, bookmarks bar, etc.)? Perhaps another way to skin this cat?
All help is greatly appreciated!!!

JerryMaguire
Posts: 16
Joined: 05 Mar 2023, 11:17

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by JerryMaguire » 03 Jun 2023, 22:28

@Xeo786


Then I found a way to block popups


First refer to
https://chromedriver.chromium.org/capabilities#h.p_ID_64
Block pop-up windows

By default, ChromeDriver configures Chrome to allow pop-up windows. If you want to block pop-ups (i.e., restore the normal Chrome behavior when it is not controlled by ChromeDriver), do the following:
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("excludeSwitches",
Arrays.asList("disable-popup-blocking"));
Then refer to here
https://github.com/Xeo786/Rufaydium-Webdriver#other-methods

Code: Select all

Chrome.capabilities.AddexcludeSwitches("disable-popup-blocking")
Rufaydium is really amazing. Using AutoHotkey + Rufaydium + WebDriver, it is really easy to use in web automation and web crawling. Compared with Python + Selenium + BeautifulSoup + WebDriver, the environment setting is relatively simple

Hope151
Posts: 2
Joined: 08 Jun 2023, 10:22

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Hope151 » 08 Jun 2023, 21:02

Dear Xeo786,

I would like to propose that you create a book with practical examples of using the excellent library Rufaydium. Examples would be public websites, with different functionalities and difficulties.

I would be one of the first readers to purchase your book.

Congratulations for the excellent work.

separateattention
Posts: 16
Joined: 19 Oct 2022, 15:30

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by separateattention » 29 Jun 2023, 10:37

Hey Xeo, can you help me with this code:

Code: Select all

Driver := "some directory"
Chrome := new Rufaydium(Driver)
Chrome.capabilities.addArg("--headless")
Chrome.capabilities.HeadlessMode := true
Chrome.capabilities.setUserProfile("Default")
Page := Chrome.NewSession()
Page.Navigate("https:...")
Page.print("C:\Users\...\Downloads\test.pdf",PrintOptions.A4_Default)
return
Even with Chrome.capabilities.addArg("--headless") and Chrome.capabilities.HeadlessMode := true, Im still get a windows that says
User is required to install "wkhtmltopdf" in order to enable pdf printing without headless mode
Any idea?

separateattention
Posts: 16
Joined: 19 Oct 2022, 15:30

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by separateattention » 06 Jul 2023, 16:31

Jasonosaj wrote:
01 Jun 2023, 13:05
I am trying to get around using FindText to identify the location of a dropdown menu element that requires physical interaction before I am able to get text sent (using send command, not Rufaydium; I can't get Rufaydium to work due my lack of understanding as to all of the elements that need to be changed for the changes to have any effect on the form).
I am able to get the X & Y coordinates of the element using the following code:

Code: Select all

myElement := session.querySelector("select[name='billingCodeSelectList']")
myElement_Location := myElement.rect()
for k, v in myElement_Location
{
    if (k == "x")
        varX := v
    If (k == "y")
        varY := v
}  
These coordinates are accurate relative to the frame, but not with regard to the window or screen. The goal is to have a script that clicks the element and then sends a text string, regardless of the resolution, color palette (e.g., night light active), etc. Can anyone come up with a way to determine the position of varX and varY relative to either the screen or window (i.e., inclusive of the tab bar, address bar, bookmarks bar, etc.)? Perhaps another way to skin this cat?
All help is greatly appreciated!!!
Could you share the html code of the dropdown? What I think you want could be done easier

cristalgrip
Posts: 36
Joined: 19 Feb 2023, 15:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 17 Jul 2023, 15:35

There is a way to have two different ahk script running with two different Chrome pages (one page for script)?

cristalgrip
Posts: 36
Joined: 19 Feb 2023, 15:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 19 Jul 2023, 15:47

cristalgrip wrote:
17 Jul 2023, 15:35
There is a way to have two different ahk script running with two different Chrome pages (one page for script)?
The problem I have is with
"Browser.capabilities.setUserProfile("Default")"

It works only for one Session. If I try the same with two simultaneous session, it crash
image.png
image.png (11.27 KiB) Viewed 3477 times
Attachments
image.png
image.png (11.27 KiB) Viewed 3477 times

Taras
Posts: 4
Joined: 08 Jul 2022, 03:04

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Taras » 28 Jul 2023, 14:37

Please, help. Rufaydium throws an error "Rufaydium is unable to access Driver Session". How can this be fixed?

The latest version of Rufaydium was released on Nov 3, 2022. I have a version of Opera that was released a few days before this update, so the error is probably not due to the version of Opera

Code: Select all

opera := new Rufaydium("operadriver.exe") ; will Download/Load operadriver
Page := opera.NewSession() 
Attachments
error.png
error.png (17.07 KiB) Viewed 3389 times

User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Xeo786 » 16 Aug 2023, 08:18

cristalgrip wrote:
19 Jul 2023, 15:47
cristalgrip wrote:
17 Jul 2023, 15:35
There is a way to have two different ahk script running with two different Chrome pages (one page for script)?
The problem I have is with
"Browser.capabilities.setUserProfile("Default")"

It works only for one Session. If I try the same with two simultaneous session, it crash
image.png
Profile folder is in used by normal chrome instance
Profile folder cannot be used by both webdriver + normal browser instance
You ahve to close all normal chrome tabs than you can create webdriver session
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Xeo786 » 16 Aug 2023, 08:22

Taras wrote:
28 Jul 2023, 14:37
Please, help. Rufaydium throws an error "Rufaydium is unable to access Driver Session". How can this be fixed?

The latest version of Rufaydium was released on Nov 3, 2022. I have a version of Opera that was released a few days before this update, so the error is probably not due to the version of Opera

Code: Select all

opera := new Rufaydium("operadriver.exe") ; will Download/Load operadriver
Page := opera.NewSession()
Opera driver failed to downlaod, you can download driver manually
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Xeo786 » 16 Aug 2023, 08:25

cristalgrip wrote:
17 Jul 2023, 15:35
There is a way to have two different ahk script running with two different Chrome pages (one page for script)?
two separate webdriver executeable with separate ports can handle separate browser sessions
just look into the example there and just change port of the one driver
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

JerryMaguire
Posts: 16
Joined: 05 Mar 2023, 11:17

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by JerryMaguire » 16 Aug 2023, 21:48

@Xeo786 can you help this issue?

ChromeDriver Cannot auto download

https://chromedriver.chromium.org/downloads/version-selection
For versions 115 and newer
Starting with M115 the ChromeDriver release process is integrated with that of Chrome. The latest Chrome + ChromeDriver releases per release channel (Stable, Beta, Dev, Canary) are available at the Chrome for Testing (CfT) availability dashboard. As a result, you might no longer have a need for version selection — you could choose any available CfT version and simply download the correspondingly-versioned ChromeDriver binary.

For automated version downloading one can use the convenient CfT JSON endpoints.

If you still have a need for version selection (e.g. to match a non-CfT Chrome binary with a compatible ChromeDriver binary), look up the Chrome binary’s MAJOR.MINOR.BUILD version in the latest-patch-versions-per-build JSON endpoints to find the corresponding ChromeDriver version.
Image

Image

separateattention
Posts: 16
Joined: 19 Oct 2022, 15:30

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by separateattention » 17 Aug 2023, 14:50

separateattention wrote:
29 Jun 2023, 10:37
Hey Xeo, can you help me with this code:

Code: Select all

Driver := "some directory"
Chrome := new Rufaydium(Driver)
Chrome.capabilities.addArg("--headless")
Chrome.capabilities.HeadlessMode := true
Chrome.capabilities.setUserProfile("Default")
Page := Chrome.NewSession()
Page.Navigate("https:...")
Page.print("C:\Users\...\Downloads\test.pdf",PrintOptions.A4_Default)
return
Even with Chrome.capabilities.addArg("--headless") and Chrome.capabilities.HeadlessMode := true, Im still get a windows that says
User is required to install "wkhtmltopdf" in order to enable pdf printing without headless mode
Any idea?
@Xeo786 sorry but cant still figure this out :(

cristalgrip
Posts: 36
Joined: 19 Feb 2023, 15:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 18 Aug 2023, 02:44

JerryMaguire wrote:
16 Aug 2023, 21:48
@Xeo786 can you help this issue?

ChromeDriver Cannot auto download

https://chromedriver.chromium.org/downloads/version-selection
For versions 115 and newer
Starting with M115 the ChromeDriver release process is integrated with that of Chrome. The latest Chrome + ChromeDriver releases per release channel (Stable, Beta, Dev, Canary) are available at the Chrome for Testing (CfT) availability dashboard. As a result, you might no longer have a need for version selection — you could choose any available CfT version and simply download the correspondingly-versioned ChromeDriver binary.

For automated version downloading one can use the convenient CfT JSON endpoints.

If you still have a need for version selection (e.g. to match a non-CfT Chrome binary with a compatible ChromeDriver binary), look up the Chrome binary’s MAJOR.MINOR.BUILD version in the latest-patch-versions-per-build JSON endpoints to find the corresponding ChromeDriver version.
Image

Image
For a temporary solution, may I suggest to downgrade Chrome to the previous version and then deactivate the autoupgrade. Of course is not the best solution but it works.

JerryMaguire
Posts: 16
Joined: 05 Mar 2023, 11:17

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by JerryMaguire » 18 Aug 2023, 04:24

cristalgrip wrote:
18 Aug 2023, 02:44
JerryMaguire wrote:
16 Aug 2023, 21:48
@Xeo786 can you help this issue?

ChromeDriver Cannot auto download

https://chromedriver.chromium.org/downloads/version-selection
For versions 115 and newer
Starting with M115 the ChromeDriver release process is integrated with that of Chrome. The latest Chrome + ChromeDriver releases per release channel (Stable, Beta, Dev, Canary) are available at the Chrome for Testing (CfT) availability dashboard. As a result, you might no longer have a need for version selection — you could choose any available CfT version and simply download the correspondingly-versioned ChromeDriver binary.

For automated version downloading one can use the convenient CfT JSON endpoints.

If you still have a need for version selection (e.g. to match a non-CfT Chrome binary with a compatible ChromeDriver binary), look up the Chrome binary’s MAJOR.MINOR.BUILD version in the latest-patch-versions-per-build JSON endpoints to find the corresponding ChromeDriver version.
Image

Image
For a temporary solution, may I suggest to downgrade Chrome to the previous version and then deactivate the autoupgrade. Of course is not the best solution but it works.
My temporary solution, I manually download the latest stable version of Chrome WebDeriver to use, then wait for @Xeo786 to update Rufaydium-Webdriver

User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Xeo786 » 18 Aug 2023, 11:23

updated the lib yesterday
they changed the download location of chromedriver
not just chromedriver
now they are also providing portable chrome for testing
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

Post Reply

Return to “Scripts and Functions (v1)”