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 (no selenium/websocket)

Post by Xeo786 » 12 May 2022, 21:51

ahk7 wrote:
12 May 2022, 14:12
I tried out the latest version but now I get all sorts of WinHttp.WinHttpRequest errors from "WDM.ahk" while the previous version I had still works (I copied all new files into a new folder, chrome and webdriver match.
It starts the session alright but as soon as I try stuff like Session.getSessionByUrl(url) Session.title() I get these errors below. Something I'm missing?
Error in #include file WDM.ahk wrote:Source: WinHttp.WinHttpRequest
Description: The URL does not use a recognized protocol
---> 169: WebRequest.Open(Method, url, false)

Source: WinHttp.WinHttpRequest
Description: This method cannot be called until the Open method has been called
---> 170: WebRequest.SetRequestHeader("Content-Type","application/json")

Source: WinHttp.WinHttpRequest
Description: This method cannot be called until the Open method has been called
---> 175: WebRequest.Send()

etc
...
Please share your code,
I suspect, You must be using old method new rundriver() , You just need to do new Rufaydium() in order to get control over chrome
https://github.com/Xeo786/Rufaydium-Webdriver#how-to-use
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

ahk7
Posts: 574
Joined: 06 Nov 2013, 16:35

Re: Rufaydium WebDriver (no selenium/websocket)

Post by ahk7 » 13 May 2022, 16:19

@Xeo786 was user error, got it working now.

Milchmann
Posts: 112
Joined: 05 Nov 2016, 08:50

Re: Rufaydium WebDriver (no selenium/websocket)

Post by Milchmann » 14 May 2022, 05:15

Hello,

I have a problem with the Chromedriver when I do not want to have the Chromedriver.exe in the same directory as the script.

Code: Select all

ChromeDriver := "c:\temp\chromedriver.exe"
Chrome := new Rufaydium(ChromeDriver)
page := Chrome.NewSession()
page.Navigate("https://www.google.de")
cc := Page.Detail()
msgbox % json.dump(cc)
In addition, I can then also no longer make Chromdriver.exe visible.

Can you help?


Thanks

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

Re: Rufaydium WebDriver (no selenium/websocket)

Post by Xeo786 » 14 May 2022, 06:26

Milchmann wrote:
14 May 2022, 05:15
Hello,

I have a problem with the Chromedriver when I do not want to have the Chromedriver.exe in the same directory as the script.

Code: Select all

ChromeDriver := "c:\temp\chromedriver.exe"
Chrome := new Rufaydium(ChromeDriver)
page := Chrome.NewSession()
page.Navigate("https://www.google.de")
cc := Page.Detail()
msgbox % json.dump(cc)
In addition, I can then also no longer make Chromdriver.exe visible.

Can you help?

Thanks
I have just updated Rufaydium, Before this day Driver were downloaded and run from A_ScriptDir now it will support Driver from desire location
therefore please get updated Rufaydium from Github,

Code: Select all

Chrome := new Rufaydium("c:\temp\chromedriver.exe") ; this will run driver from desire location, incase no driver found it will download latest driver
Chrome := new Rufaydium() ; this will run driver from A_ScriptDir, incase no driver found it will download latest driver to A_ScriptDir and then run it
same method applicable for msedgedriver.exe loaction
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

Milchmann
Posts: 112
Joined: 05 Nov 2016, 08:50

Re: Rufaydium WebDriver (no selenium/websocket)

Post by Milchmann » 14 May 2022, 09:43

Thanks, went really fast!

User avatar
hotcheesesoup
Posts: 34
Joined: 08 May 2022, 01:41

Re: Rufaydium WebDriver (no selenium/websocket)

Post by hotcheesesoup » 14 May 2022, 18:58

Hi Xeo,

How do we get the list of cookies with this?

Code: Select all

var := Session.GetCookies()
MsgBox, % var.Length() 			; returns 1 or 6 or whatever.
MsgBox, % var[1] 				; returns blank.
MsgBox, % var["channelStack"]	; this is one of the cookies on the page. returns blank.
I'm able to get the length of the array with var.Length(), but var[1] doesn't return anything. Is there some different syntax I should use?

Thanks!
-HCS

User avatar
hotcheesesoup
Posts: 34
Joined: 08 May 2022, 01:41

Re: Rufaydium WebDriver (no selenium/websocket)

Post by hotcheesesoup » 14 May 2022, 19:16

hotcheesesoup wrote:
14 May 2022, 18:58
Hi Xeo,

How do we get the list of cookies with this?

Code: Select all

var := Session.GetCookies()
MsgBox, % var.Length() 			; returns 1 or 6 or whatever.
MsgBox, % var[1] 				; returns blank.
MsgBox, % var["channelStack"]	; this is one of the cookies on the page. returns blank.
I'm able to get the length of the array with var.Length(), but var[1] doesn't return anything. Is there some different syntax I should use?

Thanks!
-HCS
Just kidding. I figured it out after finding https://developer.chrome.com/docs/extensions/reference/cookies/#type-Cookie.

Code: Select all

var := Session.GetCookies()
Loop % var.Length()
{
	MsgBox, % var[A_Index].Name	
	MsgBox, % var[A_Index].Domain	
	MsgBox, % var[A_Index].ExpirationDate	
	MsgBox, % var[A_Index].Path	
	MsgBox, % var[A_Index].StoreId
	MsgBox, % var[A_Index].Value
}
Not all of these are returning values, but perhaps these cookies don't have this information.

Thanks!
-HCS

User avatar
hotcheesesoup
Posts: 34
Joined: 08 May 2022, 01:41

Re: Rufaydium WebDriver (no selenium/websocket)

Post by hotcheesesoup » 14 May 2022, 19:31

Code: Select all

var := Session.GetCookieName("CFID")
MsgBox, % var.Name " | " var.Value " | " var.HttpOnly " | " var.Domain " | " var.Size " | " var.Priority " | " var.ExpirationDate
Similarly, not all of these are returning values even if Chrome shows they have them.

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

Re: Rufaydium WebDriver (no selenium/websocket)

Post by Xeo786 » 15 May 2022, 00:31

1. You should select user-data-dir and profile using capabilities. See docs on git for example
2. Try json.dump(result) that's how you know proper result

Code: Select all

Msgbox, %  Json.dump(Session.GetCookies())
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

User avatar
hotcheesesoup
Posts: 34
Joined: 08 May 2022, 01:41

Re: Rufaydium WebDriver (no selenium/websocket)

Post by hotcheesesoup » 15 May 2022, 01:08

Xeo786 wrote:
15 May 2022, 00:31
1. You should select user-data-dir and profile using capabilities. See docs on git for example
2. Try json.dump(result) that's how you know proper result

Code: Select all

Msgbox, %  Json.dump(Session.GetCookies())
Ahh, that's perfect! Now I can see what the attributes are actually called.

Code: Select all

cookies := Session.GetCookies()

MsgBox, % cookies[1].Domain
MsgBox, % cookies[2].Name
MsgBox, % cookies[3].Value
MsgBox, % cookies[4].Expiry
MsgBox, % cookies[5].HttpOnly
MsgBox, % cookies[6].Secure
MsgBox, % cookies[7].Path
MsgBox, % cookies[8].SameSite
These are the eight results that came back for me. The documentation for Chrome shows a few others are possible.

Thanks Xeo!
Last edited by hotcheesesoup on 15 May 2022, 02:02, edited 1 time in total.

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

Re: Rufaydium WebDriver (no selenium/websocket)

Post by Xeo786 » 15 May 2022, 01:47

hotcheesesoup wrote:
15 May 2022, 01:08
Xeo786 wrote:
15 May 2022, 00:31
1. You should select user-data-dir and profile using capabilities. See docs on git for example
2. Try json.dump(result) that's how you know proper result

Code: Select all

Msgbox, %  Json.dump(Session.GetCookies())
Ahh, that's perfect! Now I can see what the attributes are actually called.

It took me a minute to figure out how to parse the result, but this is what ended up working.

Code: Select all

cookies := JSON.Load(JSON.Dump(Session.GetCookies()))

MsgBox, % cookie.1.Domain
MsgBox, % cookie.2.Name
MsgBox, % cookie.3.Value
MsgBox, % cookie.4.Expiry
MsgBox, % cookie.5.HttpOnly
MsgBox, % cookie.6.Secure
MsgBox, % cookie.7.Path
MsgBox, % cookie.8.SameSite
These are the eight results that came back for me. The documentation for Chrome shows a few others are possible.

Thanks Xeo!
Following line do the same, no need to json.load() and Json.dump()

Code: Select all

Cookies := Session.GetCookies()
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

User avatar
hotcheesesoup
Posts: 34
Joined: 08 May 2022, 01:41

Re: Rufaydium WebDriver (no selenium/websocket)

Post by hotcheesesoup » 15 May 2022, 01:59

Of course. That's how I was doing it before but the JSON.Dump threw me off. My bad! I'll edit my post since that way is better.

User avatar
RaptorX
Posts: 371
Joined: 06 Dec 2014, 14:27
Contact:

Re: Rufaydium WebDriver (no selenium/websocket)

Post by RaptorX » 16 May 2022, 10:08

ahk7 wrote:
12 May 2022, 14:12
I tried out the latest version but now I get all sorts of WinHttp.WinHttpRequest errors from "WDM.ahk" while the previous version I had still works (I copied all new files into a new folder, chrome and webdriver match.
It starts the session alright but as soon as I try stuff like Session.getSessionByUrl(url) Session.title() I get these errors below. Something I'm missing?
Error in #include file WDM.ahk wrote:Source: WinHttp.WinHttpRequest
Description: The URL does not use a recognized protocol
---> 169: WebRequest.Open(Method, url, false)

Source: WinHttp.WinHttpRequest
Description: This method cannot be called until the Open method has been called
---> 170: WebRequest.SetRequestHeader("Content-Type","application/json")

Source: WinHttp.WinHttpRequest
Description: This method cannot be called until the Open method has been called
---> 175: WebRequest.Send()

etc
...
This was exactly the same in the previous version, your urls MUST start with "http://" or "https://", I think the library should append those if the string doesnt have it.
Projects:
AHK-ToolKit

ahk7
Posts: 574
Joined: 06 Nov 2013, 16:35

Re: Rufaydium WebDriver 1.5.0 (no selenium/websocket)

Post by ahk7 » 16 May 2022, 11:17

@RaptorX in my case it was user error, session/webdriver was already closed while still trying to send requests :oops:

Rufaydium also works with a file URI file:///C:/Path-to-Html-File/input-test.html which I use for quick testing on how to get/set values for example - so http(s) doesn't have to be inserted as such.

User avatar
RaptorX
Posts: 371
Joined: 06 Dec 2014, 14:27
Contact:

Re: Rufaydium WebDriver 1.5.0 (no selenium/websocket)

Post by RaptorX » 16 May 2022, 17:04

ahk7 wrote:
16 May 2022, 11:17
@RaptorX in my case it was user error, session/webdriver was already closed while still trying to send requests :oops:

Rufaydium also works with a file URI file:///C:/Path-to-Html-File/input-test.html which I use for quick testing on how to get/set values for example - so http(s) doesn't have to be inserted as such.
Yes I was not really specific and I assumed you were trying to access a file/page on the internet.
But basically you must specify the protocol the URL will use... it can be file:/// like in your example but it can also be ftp:// or ssh:// for that matter. The point is that the URL cannot be just like google.com, because the driver would complain about that as it did for you.
Projects:
AHK-ToolKit

Milchmann
Posts: 112
Joined: 05 Nov 2016, 08:50

Re: Rufaydium WebDriver 1.5.0 (no selenium/websocket)

Post by Milchmann » 17 May 2022, 07:27

Hi,


i have a problem with contentmenu, right click and different values with and without .cdp.
Can you help me?

Code: Select all

;~ ; https://wiki.selfhtml.org/extensions/Selfhtml/frickl.php/Beispiel:JS-Event-ondblclick.html#view_result
driver.Frame(0)
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelectorAll("#demo").length()
MsgBox % "LineNumber " A_LineNumber  " :  " driver.CDP.QuerySelectorAll("#demo").length() ; different results, why?
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelectorAll("#demo")[1].DoubleClick()  ; doesn`t work 
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelectorAll("input").length()
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelector("input").MBDown(2) ; doesn't  work right click contentmenu
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelector("input").click() ;  work
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelector("input").click(2) ;  doesn`t work , i need contentmenu

thanks

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

Re: Rufaydium WebDriver 1.5.0 (no selenium/websocket)

Post by Xeo786 » 17 May 2022, 09:23

Milchmann wrote:
17 May 2022, 07:27
Hi,


i have a problem with contentmenu, right click and different values with and without .cdp.
Can you help me?

Code: Select all

;~ ; https://wiki.selfhtml.org/extensions/Selfhtml/frickl.php/Beispiel:JS-Event-ondblclick.html#view_result
driver.Frame(0)
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelectorAll("#demo").length()
MsgBox % "LineNumber " A_LineNumber  " :  " driver.CDP.QuerySelectorAll("#demo").length() ; different results, why?
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelectorAll("input").length()
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelector("input").MBDown(2) ; doesn't  work right click contentmenu
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelector("input").click() ;  work
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelector("input").click(2) ;  doesn`t work , i need contentmenu

thanks
You are switching frame, when you switch frame it will be switched for Rufaydium Basic but CDP is whole different protocol, CDP has it own way to access elements from frame.
CDP.GetDOCwithframe() is not working... Idk why?

Code: Select all

Chrome := new Rufaydium()
Page := Chrome.getSessionByUrl("https://wiki.selfhtml.org/extensions/Selfhtml/frickl.php/Beispiel:JS-Event-ondblclick.html#view_result")
if !isobject(page)
{
	Page := Chrome.NewSession()
	Page.Navigate("https://wiki.selfhtml.org/extensions/Selfhtml/frickl.php/Beispiel:JS-Event-ondblclick.html#view_result")
}
;~ ; https://wiki.selfhtml.org/extensions/Selfhtml/frickl.php/Beispiel:JS-Event-ondblclick.html#view_result
msgbox, % Page.FramesLength()
Page.Frame(0)
MsgBox % "LineNumber " A_LineNumber  " :  " Page.QuerySelectorAll("*").length()
Page.CDP.Document()
MsgBox % "LineNumber " A_LineNumber  " :  " Page.CDP.QuerySelectorAll("*").length() ; different results, why?
CDPframe := Page.CDP.GetDOCwithframe() ; this will return with all frames and with irregular serial 
msgbox, % json.dump(CDPframe)
for k , frame in CDPframe
	MsgBox % "no " k  " :  " frame.QuerySelectorAll("8").length() ; from frame 1
Page.ParentFrame()
return
"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.5.0 (no selenium/websocket)

Post by Xeo786 » 19 May 2022, 00:05

Milchmann wrote:
17 May 2022, 07:27
Hi,


i have a problem with contentmenu, right click and different values with and without .cdp.
Can you help me?

Code: Select all

;~ ; https://wiki.selfhtml.org/extensions/Selfhtml/frickl.php/Beispiel:JS-Event-ondblclick.html#view_result
driver.Frame(0)
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelectorAll("#demo").length()
MsgBox % "LineNumber " A_LineNumber  " :  " driver.CDP.QuerySelectorAll("#demo").length() ; different results, why?
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelectorAll("#demo")[1].DoubleClick()  ; doesn`t work 
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelectorAll("input").length()
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelector("input").MBDown(2) ; doesn't  work right click contentmenu
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelector("input").click() ;  work
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelector("input").click(2) ;  doesn`t work , i need contentmenu

thanks
Just Fixed Frame Access from CDP, check out example

Code: Select all

#include, Rufaydium.ahk
Chrome := new Rufaydium()
Page := Chrome.getSessionByUrl("https://wiki.selfhtml.org/extensions/Selfhtml/frickl.php/Beispiel:JS-Event-ondblclick.html#view_result")
if !isobject(page)
{
	Page := Chrome.NewSession()
	Page.Navigate("https://wiki.selfhtml.org/extensions/Selfhtml/frickl.php/Beispiel:JS-Event-ondblclick.html#view_result")
}
MsgBox % "LineNumber " A_LineNumber  " :  Number of Tags on Main Page : " Page.QuerySelectorAll("*").length()
Page.Frame(0)
MsgBox % "LineNumber " A_LineNumber  " :  Number of Tags on Frame 1 : " Page.QuerySelectorAll("*").length()

Page.CDP.Document()
MsgBox % "LineNumber " A_LineNumber  " :  Tags on Main Page by CDP " Page.CDP.QuerySelectorAll("*").length() ; different results, why?
CDPframe := Page.CDP.Getframes() ; this will return with all frames and with irregular serial 
Msgbox, % "CDP Consider #Document as Frame `ntherefore Main page`n so Both Frames are inside Var: CDPFrame `n`n CDPFrame.Length() = " CDPframe.length()
for k , frame in CDPframe
	MsgBox % "CDP Frame no " k  " :  Number of Tags : " frame.QuerySelectorAll("*").length() ; from frame 1
Page.ParentFrame()
Page.Quit()
return
following code its actually sends right Click on page but not on browser window, of element,

Code: Select all

MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelector("input").MBDown(2) ; doesn't  work right click contentmenu
MsgBox % "LineNumber " A_LineNumber  " :  " driver.QuerySelector("input").click(2) ;  doesn`t work , i need contentmenu
You need to do following steps to access right click,
1) Get Element Coordinates using Element.Rect()
2) Get Window Coordinates using Sesssion.Rect()
3) You know what are A_ScreenHeight and A_ScreenWidth, It will get little complicated if you have more than 1 screen
4) Calculate Exact Location of element using above information
5) Send click or ControlClick to send right click on exact element location on screen

now you will got contentmenu, oh you need to get the latest lib not the release, I will include changing to v1.5.1 but I have to do few testing
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

Milchmann
Posts: 112
Joined: 05 Nov 2016, 08:50

Re: Rufaydium WebDriver 1.5.0 (no selenium/websocket)

Post by Milchmann » 19 May 2022, 02:52

Hi,

Code: Select all

MsgBox % "CDP Frame no " k  " :  Number of Tags : " frame.QuerySelectorAll("*").length() ; from frame 1
work, but

Code: Select all

MsgBox % "CDP Frame no " k  " :  Number of Tags : " frame.QuerySelectorAll("input").length()
doesn`t work, can you say why?
What I have not yet managed is right mouse click, and double click and contentmenu. With the side it can be tried yes. But does not work with other pages.
And one more thing in wdm.ahk

Code: Select all

			FileMove, % this.Dir "\" this.exe, % this.Dir "\Backup\" this.name " Version " bver1 ".exe", 1
Moves and deletes not only Chromedriver.exe, but all files in the directory....

Thanks for your great work and patience

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

Re: Rufaydium WebDriver 1.5.0 (no selenium/websocket)

Post by Xeo786 » 19 May 2022, 04:43

Milchmann wrote:
19 May 2022, 02:52

Code: Select all

MsgBox % "CDP Frame no " k  " :  Number of Tags : " frame.QuerySelectorAll("input").length()
Page/frame has no input element
Milchmann wrote:
19 May 2022, 02:52

Code: Select all

			FileMove, % this.Dir "\" this.exe, % this.Dir "\Backup\" this.name " Version " bver1 ".exe", 1
and can you replace that line and show me the result from msgbox

Code: Select all

			msgbox, % "FileMove, " this.Dir "\" this.exe ", " this.Dir "\Backup\" this.name " Version " bver1 ".exe" ", 1"
			FileMove, % this.Dir "\" this.exe, % this.Dir "\Backup\" this.name " Version " bver1 ".exe", 1
"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)”