Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post your working scripts, libraries and tools for AHK v1.1 and older
cristalgrip
Posts: 36
Joined: 19 Feb 2023, 15:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 13 Nov 2023, 15:17

Is possible to select a canvas inside an Iframe? I need to perform a click using javascript but I'm not sure if is possible. Changing frame level and the function Evaluate to send javascript code doesn't seem to work together.

User avatar
Xtra
Posts: 2751
Joined: 02 Oct 2015, 12:15

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Xtra » 14 Nov 2023, 01:25

cristalgrip wrote:
13 Nov 2023, 15:17
Is possible to select a canvas inside an Iframe? I need to perform a click using javascript but I'm not sure if is possible. Changing frame level and the function Evaluate to send javascript code doesn't seem to work together.
Sure can you just need to be in the correct iFrame.

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

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 14 Nov 2023, 04:13

Xtra wrote:
14 Nov 2023, 01:25
cristalgrip wrote:
13 Nov 2023, 15:17
Is possible to select a canvas inside an Iframe? I need to perform a click using javascript but I'm not sure if is possible. Changing frame level and the function Evaluate to send javascript code doesn't seem to work together.
Sure can you just need to be in the correct iFrame.
Can you be more specific or do an example?
One crucial thing I forgot to mention is that I'm talking about an Cross-origin iframe, so the same-origin policy doesn't allow to run any javascript if I'm not alredy "inside" the iframe.

Thx!

User avatar
Xtra
Posts: 2751
Joined: 02 Oct 2015, 12:15

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Xtra » 14 Nov 2023, 12:06

If you can get a reference to the element you are trying to click and then Rufaydium clicks do not work, there is nothing you can do. Just try to click without using any javascript.

I dont have an example that you would have access to.

Your options:
https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#cross-origin_script_api_access

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

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 15 Nov 2023, 12:15

Sorry I just found out what I was missing. My problem is that "Page.ExecuteSync()" is not very documented.

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

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by separateattention » 15 Dec 2023, 15:56

separateattention wrote:
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?

@Xeo786 hey, some insight about this, commenting out this part of the code and removing the if if this.Capabilities.HeadlessMode in the main Rufaydium.ahk seems to fix the problem and now I can print in headless mode.

screenshot.png
screenshot.png (75.24 KiB) Viewed 4859 times

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

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 28 Jan 2024, 08:35

The latest version of Microsoft Edge is 121.0.2277.83.

With this version, Rafaydium is reporting an error ("cannot find msedge binary") with the new 'Microsoft Edge WebDriver.' I've even tried downloading it manually, but the issue persists.

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

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by separateattention » 29 Jan 2024, 12:41

cristalgrip wrote:
28 Jan 2024, 08:35
The latest version of Microsoft Edge is 121.0.2277.83.

With this version, Rafaydium is reporting an error ("cannot find msedge binary") with the new 'Microsoft Edge WebDriver.' I've even tried downloading it manually, but the issue persists.
You can fix that pointing to the exe:

Code: Select all

WB := MSEdge.NewSession("C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")
Mine is set up like this:

Code: Select all

#Include Rufaydium.ahk

Driver:= "C:\Users\" A_UserName "\Documents\msedgedriver.exe"

MSEdge := new Rufaydium(Driver)
MSEdge.capabilities.addArg("--disable-dev-shm-usage")
MSEdge.capabilities.setUserProfile("Default") ; this load profile 1 according to image
WB := MSEdge.NewSession("C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")

WB.Navigate("http://...")

return


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

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 29 Jan 2024, 14:20

You are right! Absolutely perfect. Thank you very much! It's strange because when generating the new webdriver (for the new version of Edge), Rafaydium indicates the correct path.

I am really grateful to you.

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

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 27 Feb 2024, 03:38

There is a way to get the PID of Browser launched by Rufaydium WebDriver?

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

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 01 Mar 2024, 18:03

cristalgrip wrote:
27 Feb 2024, 03:38
There is a way to get the PID of Browser launched by Rufaydium WebDriver?
I've been exploring a solution in Rafaydium.ahk that involves matching the (PID) of "msedgedriver.exe" with the Parent PID of each instance of "msedge.exe". If they correspond, then the PID of msedge.exe is the one created by that particular webdriver.

However, I've encountered a significant drawback in this approach. If the browser or the webdriver are not closed correctly, the old session remains open with the same PID of "msedgedriver.exe". As a result, the PID returned is incorrect.

Code: Select all

.....

Class Session
{

	__new(i)
	{
		this.id := i.id
		this.Address := i.address
		this.debuggerAddress := i.debuggerAddress
		this.Build := i.Build
		this.name := i.name
		if i.websocketurl
			this.websocketurl := i.websocketurl
		this.currentTab := this.Send("window","GET")
		switch i.name
		{
			case "chromedriver" :
				this.CDP := new CDP(this.Address)
			case "msedgedriver" :
				this.CDP := new CDP(this.Address)
				for proc in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process WHERE Name = 'msedge.exe'")
				{
					ParentProcessId:=proc.ParentProcessId
					processid:=proc.processid
					DriverPID:= i.DriverPID
					if(DriverPID=ParentProcessId){
						msgbox, %DriverPID% - %ParentProcessId% ---- %processid% 
					}
				}	
			case "operadriver" :
				this.CDP := new CDP(this.Address)
			case "geckodriver" :
				for proc in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process WHERE Name = 'firefox.exe'")
					if ( proc.ParentProcessId = i.DriverPID)
						for proc2 in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process WHERE Name = 'firefox.exe'")
							if ( proc2.ParentProcessId = proc.processid)
							{
								this.BroswerPID := proc2.processid
								break
							} 
		}
	}
	
	......

nonchita
Posts: 3
Joined: 04 Apr 2024, 10:56

Re : Rufaydium WebDriver 1.7.2 (셀레늄/웹소켓 없음)

Post by nonchita » 04 Apr 2024, 11:18

[인용:JerryMaguire post_id=518848 time=1682261456 user_id=156994]
[인용:JerryMaguire post_id=518509 time=1682078835 user_id=156994]
@Xeo786속

팝업창의 확인 버튼을 클릭하고 Autohotkey의 WinExist(WinTitle)를 사용하여 창을 활성화하고 Send {Enter} 또는 Send {Space}를 사용하여 클릭하는 솔루션을 찾았습니다.
확인 버튼
[/인용]

참조용 코드를 제공할 수 있습니다.
[/인용]
how can use session.alret("accept") ?? plz show me sample


[Mod edit: Removed big, empty code box. Not even sure what else was intended here so leaving as-is.]

nonchita
Posts: 3
Joined: 04 Apr 2024, 10:56

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by nonchita » 04 Apr 2024, 19:41

example

Code: Select all

#Include Rufaydium-Webdriver-main\Rufaydium.ahk
Chrome := new Rufaydium()
Page := Chrome.NewSession()
url:="https://whm.ala-888.com/auth/login"

Confirm := Page.querySelectorAll(".btn.btn-info.approve")[1] ;
Confirm.Click()
>>>>a confirmation prompt window appears in Chrome

question
When I click the button through the code above, a confirmation prompt window appears in Chrome, but there is no way to click it.
Is there a separate way to click on the prompt window in Rufaydium? If so, please provide an example code.
Session.alert("accept") <<< use this??? but how can use it? plz help me


[Mod edit: Moved Codebox tags to be around the code, not at the top of the post.]

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

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Xeo786 » 21 Apr 2024, 09:09

nonchita wrote:
04 Apr 2024, 19:41
example

Code: Select all

#Include Rufaydium-Webdriver-main\Rufaydium.ahk
Chrome := new Rufaydium()
Page := Chrome.NewSession()
url:="https://whm.ala-888.com/auth/login"

Confirm := Page.querySelectorAll(".btn.btn-info.approve")[1] ;
Confirm.Click()
>>>>a confirmation prompt window appears in Chrome

question
When I click the button through the code above, a confirmation prompt window appears in Chrome, but there is no way to click it.
Is there a separate way to click on the prompt window in Rufaydium? If so, please provide an example code.
Session.alert("accept") <<< use this??? but how can use it? plz help me


[Mod edit: Moved Codebox tags to be around the code, not at the top of the post.]
those are user prompts by default they are dismiss so you can use 'Session.alert("accept")' session represents session instance which 'page' in your case.

Code: Select all

#Include Rufaydium-Webdriver-main\Rufaydium.ahk
Chrome := new Rufaydium()
Page := Chrome.NewSession()
url:="https://whm.ala-888.com/auth/login"

Confirm := Page.querySelectorAll(".btn.btn-info.approve")[1] ;
Confirm.Click()
Page .alert("accept")
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

nonchita
Posts: 3
Joined: 04 Apr 2024, 10:56

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by nonchita » 10 May 2024, 21:36

Yes, this solves the problem, but on the example site, a user prompt appears once more and if you use the accept command twice, sometimes it works and sometimes it doesn't. There are cases where the first user prompt is unconditionally clicked, but the second one is not clicked. Do you have any good ideas?

ride_quail839
Posts: 1
Joined: 14 Jun 2024, 08:20

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by ride_quail839 » 14 Jun 2024, 08:31

This library is insane, awesome work!
Xeo786 wrote:
24 Nov 2022, 05:31
thaihoa3189 wrote:
24 Nov 2022, 03:54
@Xeo786 I deleted the Chrome.Driver.Exit() in my code and replaced ABC.CDP.evaluate("alert('Hello')") with Session.ExecuteSync("alert('Hello')").
But it's still doesnt work. Cant you show the example code to Get Existing Sessions please ?
2) one can attach Webpage (even not created by Webdriver) to webdriver, it's complicated and not implemented to Rufaydium because that would also need the Browser to run in debugging mode.
This is exactly what I'm looking for. Does anybody happen to have an idea how to implement this?

jinmoo
Posts: 1
Joined: 17 Jul 2024, 04:25

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by jinmoo » 17 Jul 2024, 04:27

Hello, I want to use the function of togle device toolbar in Chrome's dev tool, but there is no response at all. Below is the script I tested. I would appreciate it if you could review it once

Code: Select all

driver = %A_ScriptDir%\chromedriver.exe
Chrome := new Rufaydium(driver,"--port=8001")
Chrome.capabilities.IncognitoMode := true

			Page := Chrome.NewSession()
			Page.Navigate("https://www.naver.com")
			deviceMetrics := ["360","460","1","true"]
			Page.CDP.call("Emulation.setDeviceMetricsOverride", deviceMetrics)

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

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Xeo786 » 02 Aug 2024, 06:03

jinmoo wrote:
17 Jul 2024, 04:27
Hello, I want to use the function of togle device toolbar in Chrome's dev tool, but there is no response at all. Below is the script I tested. I would appreciate it if you could review it once
No response just because me and AHK v1 was doing the same thing when facing error. :lol:
setDeviceMetricsOverride need object and each property should be define with case-sense.

Code: Select all

deviceMetrics := {"width":360,"height":460,"deviceScaleFactor":1,"mobile":json.true}
here you can also find an example, I am using that to take screenshot of fullpage
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

User avatar
Xtra
Posts: 2751
Joined: 02 Oct 2015, 12:15

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Xtra » 11 Aug 2024, 02:12

Xtra wrote:
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.
The problem is in the Method Send()

Code: Select all

	send(url,Method,Payload:= 0,WaitForResponse:=1)
	{
		if !instr(url,"HTTP")
			url := this.address "/" url
		if (Payload = 0) and (Method = "POST")
			Payload := Json.null
		try r := Json.load(Rufaydium.Request(url,Method,Payload,WaitForResponse)).value ; Thanks to GeekDude for his awesome cJson.ahk
		if(r.error = "chrome not reachable") ; incase someone close browser manually but session is not closed for driver
			this.quit() ; so we close session for driver at cost of one time response wait lag
		if (r || r=0)    ; This is AHK v1 we need to check for 0 so it can be returned.
			return r
	}
if (r || r=0) fixes the issue. :)
Could just return r without the checks?

User avatar
Sabestian Caine
Posts: 550
Joined: 12 Apr 2015, 03:53

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Sabestian Caine » 06 Sep 2024, 01:32

friends i am facing a problem regarding edge browser...please look once this link in which i have explained by issue in detail-
viewtopic.php?p=583840#p583840
I don't normally code as I don't code normally.

Post Reply

Return to “Scripts and Functions (v1)”