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: 760
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

18 Aug 2023, 11:27

separateattention wrote:
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 :(
if browser is not in headless mode Rufaydium will try to use whtmltopdf taht is 3rd party toll that converts html to pdf using commandline and method will be used if whtmltopdf is installed
"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)

18 Aug 2023, 12:05

Xeo786 wrote:
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
@Xeo786

now chromedriver.exe support win64, in WDM.ahk chromedriver.exe only download chromedriver-win32.zip

Is there a necessary reason?
separateattention
Posts: 16
Joined: 19 Oct 2022, 15:30

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

18 Aug 2023, 14:07

Xeo786 wrote:
18 Aug 2023, 11:27
separateattention wrote:
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 :(
if browser is not in headless mode Rufaydium will try to use whtmltopdf taht is 3rd party toll that converts html to pdf using commandline and method will be used if whtmltopdf is installed
That's my problem, the browser IS in headless mode, but still asking for "wkhtmltopdf", any idea?
peanut
Posts: 6
Joined: 08 Jan 2017, 14:51

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

20 Aug 2023, 18:39

yousef_badr23 wrote:
15 Mar 2023, 09:32
Is there a way to disable headless mode without starting a new browser object/ restarting the script?
I want to be able to fix login trouble / captcha if they occur then hide the window again, but keep headless mode as the default since errors like captcha are rare
In case you're still searching for a solution: Did you try to make the hidden headless window temporarily visible with winshow (DetectHiddenWindows, On will be needed to find the handle)?
If that's not working, you could also use the normal mode and hide/show the browser window with the window commands as needed.
peanut
Posts: 6
Joined: 08 Jan 2017, 14:51

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

20 Aug 2023, 19:18

Xeo786 wrote:
29 Mar 2023, 06:19
btw I just noticed Extension location should be base64
Image
So I made few changes in capabilities to conver exension path to base64 but still I am unable to create session with addextension, Error says cannot unzip

Code: Select all

Chrome := new Rufaydium()
extension := "C:\Users\irfan.exportho\Desktop\ChatGPT\extension_1_1_0_0.crx"
Chrome.Capabilities.Addextensions(extension) ; << cause error for me may be I am not doing proper base64 or I do not know the correct formate
page := Chrome.NewSession()
page.url := "google.com"
Xeo, thank you for creating this awesome library! :) It simplifies the work with the webdriver in a great way. :bravo:
Were you able to solve the path issue? Could it actually be that not the path should be base64-encoded but the Chrome extension file?
peanut
Posts: 6
Joined: 08 Jan 2017, 14:51

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

20 Aug 2023, 21:30

@Xeo786
How do you like the idea to add object support to ExecuteSync? Then we could hand over several objects as arguments to operate on.
Here's a working example:

Code: Select all

#include Rufaydium.ahk 
Chrome:=new Rufaydium()
page:=Chrome.NewSession(), page.url:="google.com"

e:=page.getElementsByTagName("img")[0], p:=e.parentElement
page.ExecuteSync("arguments[0].removeChild(arguments[1])", p, e)
To test it, I modified Session.ExecuteSync() based on your code in WDElement.Execute():

Code: Select all

	ExecuteSync(Script,Args*)
	{
		args_:=[], rollback:=[], origins:=[]
		for index, param in Args
			if isobject(param)
				origins.push(Origin:=param.address), regexmatch(Origin, "(.*)\/element\/(.*)$", i), param.address:=i1, rollback.push(param), args_.push({param.Element:i2})
			else args_.push(param)
		r:=this.Send("execute/sync", "POST", {"script":Script,"args":args_}, 1)
		for index, param in rollback
			param.address:=origins[index]
		return r
	}
And WDElement.Execute() would then be modified to this:

Code: Select all

	Execute(script)
	{
		return this.ExecuteSync(script,this)
	}
peanut
Posts: 6
Joined: 08 Jan 2017, 14:51

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

20 Aug 2023, 21:59

@Xeo786
I have also a different topic, page.CDP is not accessible with Edge (version 115.0.1901.203 on Win10). The creation of the object fails in this step:

Code: Select all

	__new(Address)
	{
		this.address := Address
		root := this.call("DOM.getDocument",{"depth": 0})  ;this.call("DOM.getDocument",{"":""})   <===== the query doesn't receive the document object
root.error then dumps to:
{"error": "unknown command", "message": "unknown command: unknown command: session/8e15487306850f817614e4c0d90eb46a/goog/cdp/execute", "stacktrace": "Backtrace:\n\tGetHandleVerifier [0x00007FF6C8C85422+69586]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty ..

Could it be that some security setting in Edge configuration options is needed to allow devtools access via debug port?
cristalgrip
Posts: 36
Joined: 19 Feb 2023, 15:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

21 Aug 2023, 04:59

Xeo786 wrote:
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
I keep receiving this error and Chrome is the last stable version.
Version 116.0.5845.97 (a 64 bit)
image.png
image.png (103.24 KiB) Viewed 3549 times
The same error appears if I download the chromedriver manually.

Am I the only one with this problem?
peanut
Posts: 6
Joined: 08 Jan 2017, 14:51

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

22 Aug 2023, 07:13

@cristalgrip
Does the version of chromedriver match with the browser version (116.0.5845.97)?
Bitness shouldn't be of importance as the communication between the webdriver and the browser is run through sockets.
cristalgrip
Posts: 36
Joined: 19 Feb 2023, 15:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

24 Aug 2023, 11:54

Driver: Version 116.0.5845.96
CHrome: Version 116.0.5845.97

I'll just wait the next one
peanut
Posts: 6
Joined: 08 Jan 2017, 14:51

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

24 Aug 2023, 23:54

@cristalgrip
If you want you can also install Chrome version 116.0.5845.96 to test if the issue is related to the outdated version of the webdriver.
Link from here: https://chromedriver.chromium.org/downloads/version-selection
-> Download link collection, latest Chrome + ChromeDriver releases: https://googlechromelabs.github.io/chrome-for-testing
Gedeon
Posts: 1
Joined: 06 Sep 2023, 21:59

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

06 Sep 2023, 22:26

Hello, I'm new to AHK. I have a question. Why does the following code work:

Code: Select all

MouseEvents := new mouse()
MouseEvents.press(0)
MouseEvent.move(288,258,10)
MouseEvent.release()
Session.Actions(MouseEvent)
But this code doesn't work:

Code: Select all

MouseEvents := new mouse()
MouseEvents.press(0)
x := 288
y := 256
MouseEvent.move(x, y10)
MouseEvent.release()
Session.Actions(MouseEvent)
Can someone explain why the second option doesn't work and if there are any ways to make it work?

In general, I want to find an element on a website, get its position and size, and click inside the element at a random position, something like this:

Code: Select all

MouseEvent := new mouse()
Loop {
 element := Page.QuerySelector(".selector")
 if (element.Enabled()) {
  rect := element.Rect()
  x1 := rect.x
  y1 := rect.y
  Random, x2, 0, rect.width
  Random, y2, 0, rect.height
  MouseEvent.press(0)
  MouseEvent.move(x1 + x2, y1 + y2, 10)
  MouseEvent.release()
  Page.Actions(MouseEvent)
 }
}
Can someone suggest the correct approach to implement this? Sorry for my English, and thank you for your help.
Rottweiler
Posts: 7
Joined: 14 Feb 2023, 14:55

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

23 Sep 2023, 08:34

Where is the "Getting Started" guide for Rufaydium? (I've seen the Readme.) It seems to require that I download main.zip? How do I install it and where do I put it, etc.?

Does Rufaydium require that Chrome be run in debug mode?

Thanks.
MonuKashyap
Posts: 112
Joined: 06 Jun 2016, 21:32

Re: Rufaydium WebDriver (no selenium/websocket)

05 Oct 2023, 00:06

Xeo786 wrote:
12 Apr 2022, 00:11
Examples have been moved to Github
https://github.com/Xeo786/Rufaydium-Webdriver/blob/main/README.md
Hello friend,,
I would like to know that how to import current flag setting in new rufaydium session?
because i have noticed that new chrome rufaydium session starts with all flags settings disabled,

Thanks,
Waiting for reply...
thanhlouis
Posts: 3
Joined: 19 Oct 2023, 14:03

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

19 Oct 2023, 14:11

Hello, I want to click a link like ctrl + click. The lib can do that ?
The website have a button like this:

Code: Select all

<span onclick="funcjs['open_window'](1448169, 'ads', 'ads-1448169', 'no', '');" class="go-link-youtube">Приступить к выполнению</span>
I want to click open the link but not change the current tab :crazy: :crazy:
thanhlouis
Posts: 3
Joined: 19 Oct 2023, 14:03

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

20 Oct 2023, 01:28

Q1: How to get the ahk_id or ahk_pid of the browser opened ?
Q2: Can I close the tab and no need to switch tab ? I'm in the first tab and I want to close the second tab, if script switch the tab, the browser will active. I need make the script run like I click a link with ctrl + click, wait for some minutes close the new tab. Thank you !
CarlV
Posts: 5
Joined: 15 Jan 2021, 03:11

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

02 Nov 2023, 04:37

Good morning everyone,

I wonder if this is the correct section of the form, but I’ll try writing my question here. I’ve been using this library for some time now, and I find it truly excellent. However, I’d like to know if there’s a limit to the number of connections that the Chromedriver can make on the same machine but with different users. Currently, it seems that the limit is 3, as beyond this number our scripts fail to open a new connection or, if they do, the browser opens within another user’s window.

Thank you for your attention!
I await your feedback

@Xeo786
thanhlouis
Posts: 3
Joined: 19 Oct 2023, 14:03

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

07 Nov 2023, 02:30

Hello, anyone know how to get the chrome.exe pid opened by rufaydium...
I want to use #IfWinActive but I don't know how to get the pid :(
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

07 Nov 2023, 10:51

CarlV wrote:
02 Nov 2023, 04:37
Good morning everyone,

I wonder if this is the correct section of the form, but I’ll try writing my question here. I’ve been using this library for some time now, and I find it truly excellent. However, I’d like to know if there’s a limit to the number of connections that the Chromedriver can make on the same machine but with different users. Currently, it seems that the limit is 3, as beyond this number our scripts fail to open a new connection or, if they do, the browser opens within another user’s window.

Thank you for your attention!
I await your feedback

@Xeo786
For each session use a unique port number:
Chrome := new Rufaydium(A_ScriptDir . "\chromedriver.exe", "--port=9515")
Use: 9515, 9516, 9517, 9518, 9519 etc.

I just did a project with 10 users logged into a terminal server. It works fine after setting unique ports.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

07 Nov 2023, 14:01

Reporting a possible issue:
When getting innerText and the text is 0 (zero) the returned value is blank.
I have tried every method to get it to work. CDP, ExecuteSync, querySelector etc.
In Chrome dev tools console it works like expected.
It may be caused by AHK treating 0 as false aka blank.

Example demo:

Code: Select all

#NoEnv
#SingleInstance, Ignore
SetWorkingDir %A_ScriptDir%
;----------------------------------------
global Chrome
global Driver
OnExit("CloseDriver")

StartDriver()

driver.url := "https://www.saucedemo.com/"
WaitForReadyState()

driver.ExecuteSync("document.querySelector('div.login_password > h4').innerText = '1';")
WaitForReadyState()
; Works:
MsgBox, 4096, innerText = 1, % driver.ExecuteSync("return document.querySelector('div.login_password > h4').innerText;")

driver.ExecuteSync("document.querySelector('div.login_password > h4').innerText = '0';")
WaitForReadyState()
; Fails
MsgBox, 4096, innerText = 0, % driver.ExecuteSync("return document.querySelector('div.login_password > h4').innerText;")

MsgBox done
ExitApp

StartDriver() {
	Chrome := new Rufaydium(A_ScriptDir . "\chromedriver.exe", "--port=9515")
	Chrome.capabilities.AddexcludeSwitches("enable-automation")
	Chrome.capabilities.IncognitoMode := true
    Chrome.capabilities.addArg("--disable-print-preview")
    Chrome.capabilities.addArg("--disk-cache-size=10000000")
	Chrome.capabilities.addArg("--start-maximized")
	driver := Chrome.NewSession()
}

CloseDriver() {
	Chrome.QuitAllSessions()
	Chrome.Driver.Exit()
}

WaitForReadyState() {
	driver.CDP.WaitForLoad()
    Sleep 1000
}

#Include W3C\Rufaydium.ahk
Thanks for all the work you put into this its much appreciated. :clap:

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: Bing [Bot], GollyJer and 115 guests