Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post your working scripts, libraries and tools for AHK v1.1 and older
byzod
Posts: 89
Joined: 21 Jun 2021, 06:46

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

21 Aug 2022, 00:56

Xeo786 wrote:
20 Aug 2022, 02:35
this Fx := new Rufaydium() will download chromedriver, there is geckodriver for firefox please read this
Following code will download geckodriver,

Code: Select all

Fx := new Rufaydium("geckodriver")
Fx.GetCurrentSession() is not Rufaydium class method (did you add this?), You need to learn how to get existing Session after even reloading AHK script see this,

Following function is a example to get existing FF session,

Code: Select all

FXPage := GetRufaydiumFX("someurlhere")
return

; GetRufaydiumFX(URL) gets existing session  
; stops us creatting multiple sessions again and again 
; make sure do not manually close driver / FX.driver.exit()
; by Xeo786
GetRufaydiumFX(URL)
{
	; get Firefox geckodriver / runs chrome driver if not running, download driver if available in A_ScriptDir
	; Run Firefox geckodriver with default parameters and loads deafult capabilities
	FX := new Rufaydium("geckodriver") 
	Page := FX.getSessionByUrl(URL) ; check page (created by driver) if already exist 
	if !isobject(page) ; checcking if Session with url exist
	{
		Page := FX.getSession(1,1) ; try getting first session first tab
		if isobject(page) ; if exist 
			Page.NewTab() ; create new tab instead new session
		else ; if does not exist 
			Page := FX.NewSession() ; create new session ; Page.Exit() if any session manually closed by user which causes lag
		Page.Navigate(URL) ; navigate		
	}
	return page 
}
1. I test your code but if failed, script still try to download driver while it's already downloaded (geckodriver.exe, crc32:DC49CCC3)
1.jpg
1.jpg (47.74 KiB) Viewed 5337 times
2. GetCurrentSession is not exist because it's pseudo code as I mentioned above, this explains what pseudo code means

3. Your code mentions that it only check page created by driver

Code: Select all

Page := FX.getSessionByUrl(URL) ; check page (created by driver) if already exist
So I suppose your code still can't get expected result as I said?

In case you forget, I post it again below
1. Open firefox, open target link, run ahk script below
2. Press win+F1
3. (Expect result) A message box shows: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
User avatar
hotcheesesoup
Posts: 34
Joined: 08 May 2022, 01:41

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

23 Aug 2022, 13:53

I have a new user starting to use my Rufaydium-based tools. She is on a totally fresh install of Windows 11, and I believe she has 64-bit Chrome installed since it isn't under Program Files (x86).

When I run the script, I don't receive any prompt that it is working, and a new Chrome window doesn't show up like it usually does. Normally I'll get some sort of error that it isn't working, but I don't get MsgBoxes or anything. I made a TrayTip for when Chromedriver starts running, and it doesn't even get that far.

Does Chrome's install location make any difference? Does the fact that she never had Windows 10, and thus never had IE installed, possibly cause any issues? Any ideas?

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

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

24 Aug 2022, 07:34

hotcheesesoup wrote:
23 Aug 2022, 13:53
I have a new user starting to use my Rufaydium-based tools. She is on a totally fresh install of Windows 11, and I believe she has 64-bit Chrome installed since it isn't under Program Files (x86).

When I run the script, I don't receive any prompt that it is working, and a new Chrome window doesn't show up like it usually does. Normally I'll get some sort of error that it isn't working, but I don't get MsgBoxes or anything. I made a TrayTip for when Chromedriver starts running, and it doesn't even get that far.

Does Chrome's install location make any difference? Does the fact that she never had Windows 10, and thus never had IE installed, possibly cause any issues? Any ideas?

Thanks!
-HCS
IE is not involved it uses Winhttp COM,
There were a few issues for driver existence just fixed. Make sure it's downloading and running web driver ....!
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
User avatar
Xeo786
Posts: 766
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

24 Aug 2022, 07:37

byzod wrote:
21 Aug 2022, 00:56
Xeo786 wrote:
20 Aug 2022, 02:35
this Fx := new Rufaydium() will download chromedriver, there is geckodriver for firefox please read this
Following code will download geckodriver,

Code: Select all

Fx := new Rufaydium("geckodriver")
Fx.GetCurrentSession() is not Rufaydium class method (did you add this?), You need to learn how to get existing Session after even reloading AHK script see this,

Following function is a example to get existing FF session,

Code: Select all

FXPage := GetRufaydiumFX("someurlhere")
return

; GetRufaydiumFX(URL) gets existing session  
; stops us creatting multiple sessions again and again 
; make sure do not manually close driver / FX.driver.exit()
; by Xeo786
GetRufaydiumFX(URL)
{
	; get Firefox geckodriver / runs chrome driver if not running, download driver if available in A_ScriptDir
	; Run Firefox geckodriver with default parameters and loads deafult capabilities
	FX := new Rufaydium("geckodriver") 
	Page := FX.getSessionByUrl(URL) ; check page (created by driver) if already exist 
	if !isobject(page) ; checcking if Session with url exist
	{
		Page := FX.getSession(1,1) ; try getting first session first tab
		if isobject(page) ; if exist 
			Page.NewTab() ; create new tab instead new session
		else ; if does not exist 
			Page := FX.NewSession() ; create new session ; Page.Exit() if any session manually closed by user which causes lag
		Page.Navigate(URL) ; navigate		
	}
	return page 
}
1. I test your code but if failed, script still try to download driver while it's already downloaded (geckodriver.exe, crc32:DC49CCC3)
1.jpg

2. GetCurrentSession is not exist because it's pseudo code as I mentioned above, this explains what pseudo code means

3. Your code mentions that it only check page created by driver

Code: Select all

Page := FX.getSessionByUrl(URL) ; check page (created by driver) if already exist
So I suppose your code still can't get expected result as I said?

In case you forget, I post it again below
1. Open firefox, open target link, run ahk script below
2. Press win+F1
3. (Expect result) A message box shows: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Try that code with the latest Rudaydium.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
return
Posts: 13
Joined: 06 Sep 2018, 22:22
Contact:

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

24 Aug 2022, 09:14

Impressive work.
Now I have a question.I'm writing a script for automatic login,When I use sendkey function send password to a password inputbox,It will fail.
This is my codes

Code: Select all

#Include Rufaydium.ahk
f1::
Chrome := new Rufaydium() ; this will return control over Chrome Browser
Page := Chrome.NewSession() ; creating session
Page.url :=  "https://www.autoahk.com" ; can also use page.navigate(url)
Page.getElementsByClassName("empty mobile-hidden")[0].click()
Page.getElementsByClassName("login-form-item")[1].getElementsByTagName("input")[0].sendkey("return")
Page.getElementsByClassName("login-form-item")[4].getElementsByTagName("input")[0].sendkey("123456")
Page.getElementsByClassName("login-bottom")[0].getElementsByTagName("button")[0].click()
return
User avatar
Xeo786
Posts: 766
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

25 Aug 2022, 06:04

return wrote:
24 Aug 2022, 09:14
Impressive work.
Now I have a question.I'm writing a script for automatic login,When I use sendkey function send password to a password inputbox,It will fail.
This is my codes

Code: Select all

#Include Rufaydium.ahk
f1::
Chrome := new Rufaydium() ; this will return control over Chrome Browser
Page := Chrome.NewSession() ; creating session
Page.url :=  "https://www.autoahk.com" ; can also use page.navigate(url)
Page.getElementsByClassName("empty mobile-hidden")[0].click()
Page.getElementsByClassName("login-form-item")[1].getElementsByTagName("input")[0].sendkey("return")
Page.getElementsByClassName("login-form-item")[4].getElementsByTagName("input")[0].sendkey("123456")
Page.getElementsByClassName("login-bottom")[0].getElementsByTagName("button")[0].click()
return
.value := "saomevalue" would change the value, but using sendkey() is like mimicking manual keyboard inputs while that element being focused and an element cannot be focused unless displayed. there is a method Element.Displayed() that will return element visibility status

The following code will wait until the input element is displayed.

Code: Select all

input := Page.getElementsByClassName("login-form-item")[1].getElementsByTagName("input")[0]
while !input.displayed()
	sleep, 200
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
yousef_badr23
Posts: 19
Joined: 26 Aug 2022, 07:18

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

26 Aug 2022, 10:29

When I access some streaming sites through the chrome webdriver, the websites block me with errors such as "Close Dev tools and reload" or open debugger mode in paused, then crash the site. Is there a workaround for this problem?
These sites work fine using chrome normally (unless I use developer tools)
yousef_badr23
Posts: 19
Joined: 26 Aug 2022, 07:18

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

26 Aug 2022, 10:47

yousef_badr23 wrote:
26 Aug 2022, 10:29
When I access some streaming sites through the chrome webdriver, the websites block me with errors such as "Close Dev tools and reload" or open debugger mode in paused, then crash the site. Is there a workaround for this problem?
These sites work fine using chrome normally (unless I use developer tools)
Even just navigating the sites with the chrome window opened by rufaydium crashes them
User avatar
Xeo786
Posts: 766
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

27 Aug 2022, 04:01

yousef_badr23 wrote:
26 Aug 2022, 10:47
yousef_badr23 wrote:
26 Aug 2022, 10:29
When I access some streaming sites through the chrome webdriver, the websites block me with errors such as "Close Dev tools and reload" or open debugger mode in paused, then crash the site. Is there a workaround for this problem?
These sites work fine using chrome normally (unless I use developer tools)
Even just navigating the sites with the chrome window opened by rufaydium crashes them
these sites can detect webdriver and forbid automation read this
you can try creating session using the following switch, might work for you.

Code: Select all

Chrome := new Rufaydium()
Chrome.Capabilities.addArg("--disable-blink-features=AutomationControlled") ; just disable this line webpage will detect webdriver
Page := Chrome.NewSession()
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
byzod
Posts: 89
Joined: 21 Jun 2021, 06:46

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

27 Aug 2022, 06:14

Xeo786 wrote:
24 Aug 2022, 07:37
Try that code with the latest Rudaydium.
By latest what version do you mean? I'm using 1.7.0 from here, is there any newer one?

I tried it again and it still try to download geckodriver while I already had geckodriver.exe in A_ScriptDir, I have to use explicit argument for it (new Rufaydium("geckodriver.exe") )
Besides, my region have network issue download anything from github without a proxy while your script don't support proxy, so I have to download geckodriver manually

Code I run

Code: Select all

#F1::
{
	FXPage := GetRufaydiumFX("https://www.baidu.com/s?wd=7")
	msgbox % FXPage
	return

	; GetRufaydiumFX(URL) gets existing session  
	; stops us creatting multiple sessions again and again 
	; make sure do not manually close driver / FX.driver.exit()
	; by Xeo786
	GetRufaydiumFX(URL)
	{
		; get Firefox geckodriver / runs chrome driver if not running, download driver if available in A_ScriptDir
		; Run Firefox geckodriver with default parameters and loads deafult capabilities
		FX := new Rufaydium("geckodriver.exe") 
		Page := FX.getSessionByUrl(URL) ; check page (created by driver) if already exist 
		if !isobject(page) ; checcking if Session with url exist
		{
			Page := FX.getSession(1,1) ; try getting first session first tab
			if isobject(page) ; if exist 
				Page.NewTab() ; create new tab instead new session
			else ; if does not exist 
				Page := FX.NewSession() ; create new session ; Page.Exit() if any session manually closed by user which causes lag
			Page.Navigate(URL) ; navigate		
		}
		return page 
	}

	Return
}
Result (the same as before):
1.jpg
1.jpg (51.68 KiB) Viewed 4510 times
As I said, I'm using portable firefox. If I read it correctly, binary path can only be set by NewSession(binary_location)
User avatar
Xeo786
Posts: 766
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

27 Aug 2022, 07:16

byzod wrote:
27 Aug 2022, 06:14
As I said, I'm using portable firefox. If I read it correctly, binary path can only be set by NewSession(binary_location)
Yes for portable you need to pass binary_location, and you can modify GetRufaydiumFX(URL,binary:="") accordingly

Code: Select all

#F1::
FXPage := GetRufaydiumFX("https://www.baidu.com/s?wd=7",Firefoxapplocation)
msgbox % FXPage
return

; GetRufaydiumFX(URL) gets existing session  
; stops us creatting multiple sessions again and again 
; make sure do not manually close driver / FX.driver.exit()
; by Xeo786
GetRufaydiumFX(URL,binary:="")
{
	; get Firefox geckodriver / runs chrome driver if not running, download driver if available in A_ScriptDir
	; Run Firefox geckodriver with default parameters and loads deafult capabilities
	FX := new Rufaydium("geckodriver.exe") 
	Page := FX.getSessionByUrl(URL) ; check page (created by driver) if already exist 
	if !isobject(page) ; checcking if Session with url exist
	{
		Page := FX.getSession(1,1) ; try getting first session first tab
		if isobject(page) ; if exist 
			Page.NewTab() ; create new tab instead new session
		else ; if does not exist 
			Page := FX.NewSession(binary) ; create new session ; Page.Exit() if any session manually closed by user which causes lag
		Page.Navigate(URL) ; navigate		
	}
	return page 
}
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
byzod
Posts: 89
Joined: 21 Jun 2021, 06:46

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

28 Aug 2022, 01:13

Xeo786 wrote:
27 Aug 2022, 07:16
byzod wrote:
27 Aug 2022, 06:14
As I said, I'm using portable firefox. If I read it correctly, binary path can only be set by NewSession(binary_location)
Yes for portable you need to pass binary_location, and you can modify GetRufaydiumFX(URL,binary:="") accordingly

Code: Select all

#F1::
FXPage := GetRufaydiumFX("https://www.baidu.com/s?wd=7",Firefoxapplocation)
msgbox % FXPage
return

; GetRufaydiumFX(URL) gets existing session  
; stops us creatting multiple sessions again and again 
; make sure do not manually close driver / FX.driver.exit()
; by Xeo786
GetRufaydiumFX(URL,binary:="")
{
	; get Firefox geckodriver / runs chrome driver if not running, download driver if available in A_ScriptDir
	; Run Firefox geckodriver with default parameters and loads deafult capabilities
	FX := new Rufaydium("geckodriver.exe") 
	Page := FX.getSessionByUrl(URL) ; check page (created by driver) if already exist 
	if !isobject(page) ; checcking if Session with url exist
	{
		Page := FX.getSession(1,1) ; try getting first session first tab
		if isobject(page) ; if exist 
			Page.NewTab() ; create new tab instead new session
		else ; if does not exist 
			Page := FX.NewSession(binary) ; create new session ; Page.Exit() if any session manually closed by user which causes lag
		Page.Navigate(URL) ; navigate		
	}
	return page 
}

Thanks, it's working with new firefox session created by rufaydium, but is it possible to get anything from existing session created by me?
For example get page title from usercenter.html which is only accessible when user logged in

pseudo code

Code: Select all

#F1::
Firefoxapplocation := "C:\App\Firefox\firefox.exe"
FXPage := GetRufaydiumFXFromUser("https://www.demo-site.com/usercenter.html", Firefoxapplocation)
msgbox % FXPage.Title
return

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

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

29 Aug 2022, 01:13

byzod wrote:
28 Aug 2022, 01:13
Thanks, it's working with new firefox session created by rufaydium, but is it possible to get anything from existing session created by me?
For example get page title from usercenter.html which is only accessible when user logged in
No, a Normal running browser is not a Webdriver session.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
byzod
Posts: 89
Joined: 21 Jun 2021, 06:46

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

29 Aug 2022, 07:08

Xeo786 wrote:
29 Aug 2022, 01:13
byzod wrote:
28 Aug 2022, 01:13
Thanks, it's working with new firefox session created by rufaydium, but is it possible to get anything from existing session created by me?
For example get page title from usercenter.html which is only accessible when user logged in
No, a Normal running browser is not a Webdriver session.
OK, thanks

btw do you know any possible way to do so? I'm (trying to) writing a script to assist browsing experience that can't be done only by greasemonkey (print to pdf for example)
User avatar
Xeo786
Posts: 766
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

29 Aug 2022, 08:33

byzod wrote:
29 Aug 2022, 07:08
Xeo786 wrote:
29 Aug 2022, 01:13
byzod wrote:
28 Aug 2022, 01:13
Thanks, it's working with new firefox session created by rufaydium, but is it possible to get anything from existing session created by me?
For example get page title from usercenter.html which is only accessible when user logged in
No, a Normal running browser is not a Webdriver session.
OK, thanks

btw do you know any possible way to do so? I'm (trying to) writing a script to assist browsing experience that can't be done only by greasemonkey (print to pdf for example)
You can read all about PDF printing here.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
byzod
Posts: 89
Joined: 21 Jun 2021, 06:46

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

30 Aug 2022, 06:45

Xeo786 wrote:
29 Aug 2022, 08:33
byzod wrote:
29 Aug 2022, 07:08
Xeo786 wrote:
29 Aug 2022, 01:13
byzod wrote:
28 Aug 2022, 01:13
Thanks, it's working with new firefox session created by rufaydium, but is it possible to get anything from existing session created by me?
For example get page title from usercenter.html which is only accessible when user logged in
No, a Normal running browser is not a Webdriver session.
OK, thanks

btw do you know any possible way to do so? I'm (trying to) writing a script to assist browsing experience that can't be done only by greasemonkey (print to pdf for example)
You can read all about PDF printing here.
It's just an example, not exactly all what I'm try to do
The keywords is that can't be done only by greasemonkey, not printing to pdf
Can rufaydium print usercenter.html we mentioned before? It can't access to that page at all
User avatar
Xeo786
Posts: 766
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

31 Aug 2022, 02:10

byzod wrote:
30 Aug 2022, 06:45
It's just an example, not exactly all what I'm try to do
The keywords is that can't be done only by greasemonkey, not printing to pdf
Can rufaydium print usercenter.html we mentioned before? It can't access to that page at all
you can create a Session with an existing user profile that has all your user settings including access to Greasemonkey, look into capabilities, setUserProfile() method
Then save that HTML somewhere FileAppend
now you can use wkhtmltopdf or Rufaydium navigate to save html and print pdf.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
yousef_badr23
Posts: 19
Joined: 26 Aug 2022, 07:18

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

31 Aug 2022, 02:23

After reinstalling firefox, I keep getting this error.
image.png
image.png (30.99 KiB) Viewed 3570 times
I deleted and replaced gecko driver multiple times but it is not helping.
User avatar
Xeo786
Posts: 766
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

31 Aug 2022, 05:25

yousef_badr23 wrote:
31 Aug 2022, 02:23
After reinstalling firefox, I keep getting this error. image.png
I deleted and replaced gecko driver multiple times but it is not helping.
you do not need to pass binary unless you are using portable firefox, Let the driver find the find it first, if it does not detect then you can pass,

That's capabilities issue, not accepting excludeswitches as parameter,
but FireFoxCapabilities class do not has any AddexcludeSwitches(switch) method.

I got it working on my system,

Code: Select all

#Include, %A_ScriptDir%\..\Rufaydium-Webdriver
#include Rufaydium.ahk
FF := new Rufaydium("geckodriver")
FFPage := FF.NewSession()
FFPage.url := "https://www.autohotkey.com/boards/"
msgbox, press f12 to close 
return


f12::
FF := new Rufaydium("geckodriver")
FF.QuitAllSessions() ; close all session 
FF.Driver.Exit() ; then exits driver
msgbox, all session closed and Driver Exitted
return
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
ctech
Posts: 1
Joined: 05 Sep 2022, 07:22

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

05 Sep 2022, 08:47

Hi!

this looks amazing and seems to be exactly what I was looking for! :D

Unfortunately I'm running in a bit of trouble while trying to load a session with a user Profile.

Code: Select all

#Include Rufaydium.ahk
Chrome := new Rufaydium("chromedriver.exe")
Chrome.capabilities.setUserProfile("Profile 1")
Page := Chrome.NewSession()
Page.Navigate("https://www.autohotkey.com/")
This works if I have no chrome window open. However if there are other Chrome windows open (not created by chromedriver.exe) it stops working and produces the following error:
image.png
image.png (8.97 KiB) Viewed 3264 times
Unhiding the chromedriver window produces the following message when trying to create the session:
image.png
image.png (2.56 KiB) Viewed 3264 times
which roughly translates to "Is being opened in a currunt browser session."

Chrome starts with the correct profile but it seems there is no Session attached to it (or at least not available in the "Page" variable).

This also occurs if I have chrome open with a different profile, e.g. Profile 2.

Also if I try to create a second session in the first scenario where no instance of chrome was open before launching the script, it gives me the same error. Without loading a profile I can create several sessions with Chrome.NewSession() without problem.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 139 guests