Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post your working scripts, libraries and tools for AHK v1.1 and older
anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by anhnha » 04 Dec 2022, 12:44

With Chrome.ahk you could open an array of URLs and navigate them in parallel as this.
viewtopic.php?t=64183

Would it be possible to do this with Rufaydium.ahk?

Code: Select all

Chrome := new Rufaydium()
Page1 := Chrome.NewSession()
Page1.Navigate("https://www.google.com/")
Page1.NewTab() 	; create new window / tab but Page1 session pointer will remain same 
Page1.Navigate("https://www.autohotkey.com/boards/viewtopic.php?t=94276") ; navigating 2nd tab
Page1.NewTab() 
Page1.Navigate("https://www.amazon.com/") ; navigating 3rd tab
This one works but a bit slow as you have two move to new tabs several 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 » 05 Dec 2022, 03:24

anhnha wrote:
04 Dec 2022, 12:44
With Chrome.ahk you could open an array of URLs and navigate them in parallel as this.
viewtopic.php?t=64183

Would it be possible to do this with Rufaydium.ahk?

Code: Select all

Chrome := new Rufaydium()
Page1 := Chrome.NewSession()
Page1.Navigate("https://www.google.com/")
Page1.NewTab() 	; create new window / tab but Page1 session pointer will remain same 
Page1.Navigate("https://www.autohotkey.com/boards/viewtopic.php?t=94276") ; navigating 2nd tab
Page1.NewTab() 
Page1.Navigate("https://www.amazon.com/") ; navigating 3rd tab
This one works but a bit slow as you have two move to new tabs several times.
hmm, interesting. Session.URL also navigates to url and there is session.Navigate() also does the same thing.
Just update Rufaydium, from now on Session.Navigate(urls*) accepts multiple urls

Code: Select all

Chrome := new Rufaydium()
Page1 := Chrome.NewSession()
Page1.Navigate("https://www.google.com/") ; this will navigates to site 
; but this one navigates the active tab to the first URL and all other URL to new tab for each, Last tab will be the active tab
Page1.Navigate("https://www.google.com/","https://www.autohotkey.com/boards/viewtopic.php?t=94276","https://www.amazon.com/")
"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.7.2 (no selenium/websocket)

Post by Milchmann » 05 Dec 2022, 07:22

With the version greater date 14.10.22 click() no longer works for certain queries.

Code: Select all

driver.QuerySelector("body > div.MenuOuter > div.MenuTableContainer > table > tbody > tr:nth-child(3)").click()
return

Code: Select all

driver.QuerySelector("body > div.MenuOuter > div.MenuTableContainer > table > tbody > tr:nth-child(3)").click()
---- Z:\ahk\lib\Rufaydium.ahk
668: Return,this.findelement(by.selector,Path)
621: r := this.Send("element","POST",{"using":u,"value":v},1)
---- Z:\ahk\lib\JSON.ahk
258: Return,StrGet(&buf, size, "UTF-16")
---- Z:\ahk\lib\Rufaydium.ahk
089: p := RegExReplace(p,"\\\\uE(\d+)","\uE$1") (0.03)
098: Return,Rufaydium.WebRequest.responseText
---- Z:\ahk\lib\JSON.ahk
283: Return,result
---- Z:\ahk\lib\Rufaydium.ahk
310: if (r.error = "chrome not reachable")  
312: if r  
314: Return,r
622: For i,elementid in r
624: if instr(elementid,"no such")  
626: address := RegExReplace(this.address "/element/" elementid,"(\/shadow\/.*)\/element","/element")
627: address := RegExReplace(address "/element/" elementid,"(\/element\/.*)\/element","/element")
628: Return,New WDElement(address,i)
---- Z:\ahk\lib\WDElements.ahk
008: This.Address := Address  
009: This.Element := Element  
010: }
067: if slient  
068: Return,this.Execute("arguments[0].click()")
316: Origin := this.Address
317: RegExMatch(Origin,"(.*)\/element\/(.*)$",i)  
318: this.address := i1  
319: r := this.ExecuteSync(script,{This.Element:i2})
---- Z:\ahk\lib\Rufaydium.ahk
698: Return,this.Send("execute/sync","POST", { "script":Script,"args":[Args*]},1)
---- Z:\ahk\lib\JSON.ahk
258: Return,StrGet(&buf, size, "UTF-16")
---- Z:\ahk\lib\Rufaydium.ahk
089: p := RegExReplace(p,"\\\\uE(\d+)","\uE$1") (0.03)
098: Return,Rufaydium.WebRequest.responseText
---- Z:\ahk\lib\JSON.ahk
283: Return,result
---- Z:\ahk\lib\Rufaydium.ahk
310: if (r.error = "chrome not reachable")  
312: if r  
314: Return,r
---- Z:\ahk\lib\WDElements.ahk
320: this.address := Origin  
321: Return,r
with older version , works

Code: Select all

driver.QuerySelector("body > div.MenuOuter > div.MenuTableContainer > table > tbody > tr:nth-child(3)").click()  
---- Z:\ahk\lib\Rufaydium.ahk
609: Return,this.findelement(by.selector,Path)
562: r := this.Send("element","POST",{"using":u,"value":v},1)
---- Z:\ahk\lib\JSON.ahk
258: Return,StrGet(&buf, size, "UTF-16")
---- Z:\ahk\lib\Rufaydium.ahk
088: p := RegExReplace(p,"\\\\uE(\d+)","\uE$1") (0.03)
097: Return,Rufaydium.WebRequest.responseText
---- Z:\ahk\lib\JSON.ahk
283: Return,result
---- Z:\ahk\lib\Rufaydium.ahk
308: if (r.error = "chrome not reachable")  
310: if r  
312: Return,r
563: For i,elementid in r
565: if instr(elementid,"no such")  
567: address := RegExReplace(this.address "/element/" elementid,"(\/shadow\/.*)\/element","/element")
568: address := RegExReplace(address "/element/" elementid,"(\/element\/.*)\/element","/element")
569: Return,New WDElement(address,i)
---- Z:\ahk\lib\WDElements.ahk
008: This.Address := Address  
009: This.Element := Element  
010: }
067: Return,this.Send("click","POST",{"":""})
---- Z:\ahk\lib\JSON.ahk
258: Return,StrGet(&buf, size, "UTF-16")
---- Z:\ahk\lib\Rufaydium.ahk
088: p := RegExReplace(p,"\\\\uE(\d+)","\uE$1") (0.08)
097: Return,Rufaydium.WebRequest.responseText
---- Z:\ahk\lib\JSON.ahk
283: Return,result
---- Z:\ahk\lib\Rufaydium.ahk
308: if (r.error = "chrome not reachable")  
310: if r  
312: Return,r
288: }

Can you help?

Thanks

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 » 05 Dec 2022, 08:01

Milchmann wrote:
05 Dec 2022, 07:22
With the version greater date 14.10.22 click() no longer works for certain queries.

Code: Select all

driver.QuerySelector("body > div.MenuOuter > div.MenuTableContainer > table > tbody > tr:nth-child(3)").click()
return

Code: Select all

driver.QuerySelector("body > div.MenuOuter > div.MenuTableContainer > table > tbody > tr:nth-child(3)").click()
---- Z:\ahk\lib\Rufaydium.ahk
668: Return,this.findelement(by.selector,Path)
621: r := this.Send("element","POST",{"using":u,"value":v},1)
---- Z:\ahk\lib\JSON.ahk
258: Return,StrGet(&buf, size, "UTF-16")
---- Z:\ahk\lib\Rufaydium.ahk
089: p := RegExReplace(p,"\\\\uE(\d+)","\uE$1") (0.03)
098: Return,Rufaydium.WebRequest.responseText
---- Z:\ahk\lib\JSON.ahk
283: Return,result
---- Z:\ahk\lib\Rufaydium.ahk
310: if (r.error = "chrome not reachable")  
312: if r  
314: Return,r
622: For i,elementid in r
624: if instr(elementid,"no such")  
626: address := RegExReplace(this.address "/element/" elementid,"(\/shadow\/.*)\/element","/element")
627: address := RegExReplace(address "/element/" elementid,"(\/element\/.*)\/element","/element")
628: Return,New WDElement(address,i)
---- Z:\ahk\lib\WDElements.ahk
008: This.Address := Address  
009: This.Element := Element  
010: }
067: if slient  
068: Return,this.Execute("arguments[0].click()")
316: Origin := this.Address
317: RegExMatch(Origin,"(.*)\/element\/(.*)$",i)  
318: this.address := i1  
319: r := this.ExecuteSync(script,{This.Element:i2})
---- Z:\ahk\lib\Rufaydium.ahk
698: Return,this.Send("execute/sync","POST", { "script":Script,"args":[Args*]},1)
---- Z:\ahk\lib\JSON.ahk
258: Return,StrGet(&buf, size, "UTF-16")
---- Z:\ahk\lib\Rufaydium.ahk
089: p := RegExReplace(p,"\\\\uE(\d+)","\uE$1") (0.03)
098: Return,Rufaydium.WebRequest.responseText
---- Z:\ahk\lib\JSON.ahk
283: Return,result
---- Z:\ahk\lib\Rufaydium.ahk
310: if (r.error = "chrome not reachable")  
312: if r  
314: Return,r
---- Z:\ahk\lib\WDElements.ahk
320: this.address := Origin  
321: Return,r
with older version , works

Code: Select all

driver.QuerySelector("body > div.MenuOuter > div.MenuTableContainer > table > tbody > tr:nth-child(3)").click()  
---- Z:\ahk\lib\Rufaydium.ahk
609: Return,this.findelement(by.selector,Path)
562: r := this.Send("element","POST",{"using":u,"value":v},1)
---- Z:\ahk\lib\JSON.ahk
258: Return,StrGet(&buf, size, "UTF-16")
---- Z:\ahk\lib\Rufaydium.ahk
088: p := RegExReplace(p,"\\\\uE(\d+)","\uE$1") (0.03)
097: Return,Rufaydium.WebRequest.responseText
---- Z:\ahk\lib\JSON.ahk
283: Return,result
---- Z:\ahk\lib\Rufaydium.ahk
308: if (r.error = "chrome not reachable")  
310: if r  
312: Return,r
563: For i,elementid in r
565: if instr(elementid,"no such")  
567: address := RegExReplace(this.address "/element/" elementid,"(\/shadow\/.*)\/element","/element")
568: address := RegExReplace(address "/element/" elementid,"(\/element\/.*)\/element","/element")
569: Return,New WDElement(address,i)
---- Z:\ahk\lib\WDElements.ahk
008: This.Address := Address  
009: This.Element := Element  
010: }
067: Return,this.Send("click","POST",{"":""})
---- Z:\ahk\lib\JSON.ahk
258: Return,StrGet(&buf, size, "UTF-16")
---- Z:\ahk\lib\Rufaydium.ahk
088: p := RegExReplace(p,"\\\\uE(\d+)","\uE$1") (0.08)
097: Return,Rufaydium.WebRequest.responseText
---- Z:\ahk\lib\JSON.ahk
283: Return,result
---- Z:\ahk\lib\Rufaydium.ahk
308: if (r.error = "chrome not reachable")  
310: if r  
312: Return,r
288: }

Can you help?

Thanks
Webdriver + browser are also getting updates and Rufaydium has to follow that, I have also noticed few elements do not accept click, unless we use JS,

Webpages know that if a click is sent by a user or not, using istrusted parameter
The following code will send click using Webdriver API, generating a click that has istrusted always being true, in rare cases, this does not work, we need to send a JS click()

Code: Select all

Element.click(0) ; will send click from Webdriver API
The following code Sends the traditional Javascript click(), most of the time this work,

Code: Select all

Element.click()  ; default value is 1()
I suggest you should use Element.click(0) instead
"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.7.2 (no selenium/websocket)

Post by Milchmann » 05 Dec 2022, 08:51

Thanks,

works with

.click(0)

👍

Sadaosh1970
Posts: 19
Joined: 29 Nov 2022, 06:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by Sadaosh1970 » 05 Dec 2022, 19:08

@Xeo786 , Please!
Newbie question :headwall: :
Is it possible to use "methods" inside a function, as in the example below?

Code: Select all

click_By_Class(Value, position, number_searching, time_interval) {
	Loop, %number_searching% {
		Elements := Page.getElementsbyClassName(Value) ; (is it possíble ?)
		
		if !IsObject(Elements) {
			Sleep %time_interval%
		}
		else {
			Elements := Page.getElementsbyClassName(Value)[position].click()
			code (........)
		}
	}
}

User avatar
boiler
Posts: 16901
Joined: 21 Dec 2014, 02:44

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by boiler » 05 Dec 2022, 19:24

You need to make the reference to the Elements object a global variable or pass it to the function. Otherwise, the function isn’t aware of it because it’s outside of its scope.

anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by anhnha » 05 Dec 2022, 20:16

hmm, interesting. Session.URL also navigates to url and there is session.Navigate() also does the same thing.
Just update Rufaydium, from now on Session.Navigate(urls*) accepts multiple urls

Code: Select all

Chrome := new Rufaydium()
Page1 := Chrome.NewSession()
Page1.Navigate("https://www.google.com/") ; this will navigates to site 
; but this one navigates the active tab to the first URL and all other URL to new tab for each, Last tab will be the active tab
Page1.Navigate("https://www.google.com/","https://www.autohotkey.com/boards/viewtopic.php?t=94276","https://www.amazon.com/")
Thanks.
It works very nice now.
Can I set the first tab to be the active one instead (as in Chrome.ahk as well)? Assuming that I open three tabs in parallel and I want to check the first tab while leaving the second and third tab loading?
If I put the url that I want to check first at the end of the URL list then it would be loaded last and I can't use the time during the program loading the other urls.

Another question:
Would there is simple way to hide or activate the chrome window which was opened by Rufaydium?
I can use WinActivate by Autohotkey but this is not the ideal solution as it's hard to distinguish between my normal Chrome (with different profile) that I opened manually with Chrome window opened by Rufaydium.
The ahk_class of these two Chrome windows are same. I can use title but it's not reliable.

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 » 06 Dec 2022, 02:30

anhnha wrote:
05 Dec 2022, 20:16
Can I set the first tab to be the active one instead (as in Chrome.ahk as well)? Assuming that I open three tabs in parallel and I want to check the first tab while leaving the second and third tab loading?
yah, you can use .getSessionByUrl(url) or .getSessionByTitle(Title) based on .Switch(Handle)

Code: Select all

Handle := Page1.currentTab ; get tab's handle 
Page1.Navigate("https://www.google.com/","https://www.autohotkey.com/boards/viewtopic.php?t=94276","https://www.amazon.com/")
Page1.Switch(Handle); switch to handle 
you can use CDP to open tabs without waiting for them to finish loading

Code: Select all

Chrome := new Rufaydium()
urls := ["https://www.autohotkey.com/boards/viewforum.php?f=4","https://chromedevtools.github.io/devtools-protocol","https://github.com/Xeo786/Rufaydium-Webdriver"]
Page := Chrome.NewSession()
Page.url := "about:Blank"
for i, url  in urls
    Page.CDP.CreateTarget(url)
anhnha wrote:
05 Dec 2022, 20:16
If I put the URL that I want to check first at the end of the URL list then it would be loaded last and I can't use the time during the program loading the other URLs.
as I said you can switch to any desired URL
let's continue the above code as URLs are already opened

Code: Select all

urls := ["https://www.autohotkey.com/boards/viewforum.php?f=4","https://chromedevtools.github.io/devtools-protocol","https://github.com/Xeo786/Rufaydium-Webdriver"]
for i, url in urls
{
    P := Chrome.getSessionByUrl(url)
    msgbox, % "You Get accessed and have activated tab with`nURL: " P.url "`nTitle: " P.title
}
anhnha wrote:
05 Dec 2022, 20:16
Another question:
Would there is a simple way to hide or activate the chrome window which was opened by Rufaydium?
I can use WinActivate by Autohotkey but this is not the ideal solution as it's hard to distinguish between my normal Chrome (with a different profile) that I opened manually with the Chrome window opened by Rufaydium.
The ahk_class of these two Chrome windows is the same. I can use the title but it's not reliable.
You can not only control the window stats but also the position and size using Rufaydium's session-window-position-and-location

Code: Select all

Page.Maximize() 
Page.Minimize()
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by anhnha » 06 Dec 2022, 10:23

Thanks,
Using CDP to open is much faster now.
I was wondering why it was much slower than Chrome.ahk.

Code: Select all

Page.url := "about:Blank"
Should we always add this?
How can I get rid of it?
I tried this but didn't work.

Code: Select all

Chrome := new Rufaydium()
urls := ["https://www.autohotkey.com/boards/viewforum.php?f=4","https://chromedevtools.github.io/devtools-protocol","https://github.com/Xeo786/Rufaydium-Webdriver"]
Page := Chrome.NewSession()
Page.url := "about:Blank"
for i, url  in urls
    Page.CDP.CreateTarget(url)
session:= Chrome.getSession(1)
SendInput ^w
If I have 3 urls which are opened in three tabs,
The CDP loading would be in the sequence url1 (tab1) -> url2 (tab 2) -> url3 (tab3).
So after loading this, the active one is tab3.
I can move to tab1 by getting the handle of tab1 using url1 .getSessionByUrl(url) and .Switch(Handle) as you mentioned.
However, is there anyway to keep tab1 always active even when CDP loading for tab2, tab3 is still going?
Last edited by anhnha on 06 Dec 2022, 21:17, edited 6 times in total.

anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by anhnha » 06 Dec 2022, 16:30

Code: Select all

[Codebox=autohotkey file=Untitled.ahk]#Include, %A_ScriptDir%\..\Rufaydium-Webdriver
#include Rufaydium.ahk

Chrome := new Rufaydium("geckodriver")
Page := Chrome .NewSession()
Page.url := "https://www.autohotkey.com/boards/"
return

f10::
; state:= webdriver is downloaded/loaded and the new session is created (as above)
; if(!state) 
; download/load webdriver and open a new session 
; do some other suff here

f11::
Chrome := new Rufaydium("geckodriver")
Chrome.QuitAllSessions() ; close all session 
Chrome.Driver.Exit() ; then exits driver
msgbox, all session closed and Driver Exitted
return[/Codebox]
I have a program like this. In the first run, it'll download/load webdriver, make new session, navigate url.
When the hotkey f10 is pressed, how can I check if webdriver was downloaded/loaded, the new session was created and navigated or not?
The problem is that if I accidently close by click X in the window or press f11 then I don't know how to check check if webdriver was downloaded/loaded, the new session was created and navigated or not in the f10 hotkey section.

mora145
Posts: 57
Joined: 25 Jun 2022, 15:31

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by mora145 » 07 Dec 2022, 01:14

Hello
I am just starting to use Rufaydium. Thanks for keeping this library active and updated :)

There are many videos showing your library and the documentation is excellent. So I guess that's why almost nobody requires support. I love the simplicity and that it can be used in the background, not like other libraries that require accessibility to be used. So yes, it is still very important to have your library among our tools.

I am trying to do some scrolling in this window. I can't get it to scroll correctly but it's the screen behind me that moves. How can I do it?
Screenshot_81.jpg
Screenshot_81.jpg (58.94 KiB) Viewed 2214 times
On the other hand, I have this error, it always appears when I have another profile open, so it doesn't let to run the right profile.

Code: Select all

Chrome := new Rufaydium()
interaction := New Scroll()
Page := Chrome.capabilities.setUserProfile("Academia")
Page := Chrome.NewSession()
Screenshot_82.jpg
Screenshot_82.jpg (19.65 KiB) Viewed 2214 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 » 07 Dec 2022, 02:22

anhnha wrote:
06 Dec 2022, 16:30
I have a program like this. In the first run, it'll download/load webdriver, make new session, navigate url.
When the hotkey f10 is pressed, how can I check if webdriver was downloaded/loaded, the new session was created and navigated or not?
The problem is that if I accidently close by click X in the window or press f11 then I don't know how to check check if webdriver was downloaded/loaded, the new session was created and navigated or not in the f10 hotkey section.
You can check if the driver working or not by using Status() method

Code: Select all

Chrome := new Rufaydium()
msgbox, % Chrome.Status()
Chrome.Driver.Exit()
msgbox, % Chrome.Status()
Just updated Use latest Rufaydium, to check Drive Location, Rufaydium Check for driver if a driver with a specific name and port is running, Rufaydium will access that driver (ignoring the location) to acquire access to the already running session connected to that driver.
now the issue is All following Rufaydium Class objects share the same driver and sessions but location information

Code: Select all

Chrome1 := new Rufaydium(A_desktop "\chromedriver.exe")
Msgbox, % Chrome1.Driver.Location
Chrome2 := new Rufaydium() ; this will also access the running driver but provide you wrong location and I am looking for a way to fix that
Msgbox, % Chrome2.Driver.Location
Chrome3 := new Rufaydium("E:\chromedriver.exe")
Msgbox, % Chrome3.Driver.Location ; this also showing the passing location
I will soon fix this bug, because we may get Process location using PID.

Edit:
Just fixed that issue and checked. It will get the Location of the running driver from now on
Spoiler
Last edited by Xeo786 on 07 Dec 2022, 02:36, edited 2 times in total.
"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 » 07 Dec 2022, 02:25

mora145 wrote:
07 Dec 2022, 01:14
I am trying to do some scrolling in this window. I can't get it to scroll correctly but it's the screen behind me that moves. How can I do it?
Screenshot_81.jpg
Get all elements having innertext unfollow, now you can use element[x].focus it will automatically scroll to the element and focus that element
if you use New Scroll() it will scroll the stuff according to the mouse pointer location, therefore you also need to use New Mouse() to place the pointer to such a location so it gets the desired scrollbar act upon.
mora145 wrote:
07 Dec 2022, 01:14
On the other hand, I have this error, it always appears when I have another profile open, so it doesn't let to run the right profile.

Code: Select all

Chrome := new Rufaydium()
interaction := New Scroll()
Page := Chrome.capabilities.setUserProfile("Academia")
Page := Chrome.NewSession()
Screenshot_82.jpg
The issue is that profile is being accessed by normal chrome, close are chrome processes, check the task manager that chrome is not running anymore and then try again.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by anhnha » 07 Dec 2022, 03:24

anhnha wrote:
06 Dec 2022, 10:23
Thanks,
Using CDP to open is much faster now.
I was wondering why it was much slower than Chrome.ahk.

Code: Select all

Page.url := "about:Blank"
Should we always add this?
How can I get rid of it?
I tried this but didn't work.

Code: Select all

Chrome := new Rufaydium()
urls := ["https://www.autohotkey.com/boards/viewforum.php?f=4","https://chromedevtools.github.io/devtools-protocol","https://github.com/Xeo786/Rufaydium-Webdriver"]
Page := Chrome.NewSession()
Page.url := "about:Blank"
for i, url  in urls
    Page.CDP.CreateTarget(url)
session:= Chrome.getSession(1)
SendInput ^w
If I have 3 urls which are opened in three tabs,
The CDP loading would be in the sequence url1 (tab1) -> url2 (tab 2) -> url3 (tab3).
So after loading this, the active one is tab3.
I can move to tab1 by getting the handle of tab1 using url1 .getSessionByUrl(url) and .Switch(Handle) as you mentioned.
However, is there anyway to keep tab1 always active even when CDP loading for tab2, tab3 is still going?
Thanks for the help.
Do you have any idea to get rid of the blank page here?

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 » 07 Dec 2022, 04:14

anhnha wrote:
07 Dec 2022, 03:24
anhnha wrote:
06 Dec 2022, 10:23
Thanks,
Using CDP to open is much faster now.
I was wondering why it was much slower than Chrome.ahk.

Code: Select all

Page.url := "about:Blank"
Should we always add this?
How can I get rid of it?
I tried this but didn't work.

Code: Select all

Chrome := new Rufaydium()
urls := ["https://www.autohotkey.com/boards/viewforum.php?f=4","https://chromedevtools.github.io/devtools-protocol","https://github.com/Xeo786/Rufaydium-Webdriver"]
Page := Chrome.NewSession()
Page.url := "about:Blank"
for i, url  in urls
    Page.CDP.CreateTarget(url)
session:= Chrome.getSession(1)
SendInput ^w
If I have 3 urls which are opened in three tabs,
The CDP loading would be in the sequence url1 (tab1) -> url2 (tab 2) -> url3 (tab3).
So after loading this, the active one is tab3.
I can move to tab1 by getting the handle of tab1 using url1 .getSessionByUrl(url) and .Switch(Handle) as you mentioned.
However, is there anyway to keep tab1 always active even when CDP loading for tab2, tab3 is still going?
Thanks for the help.
Do you have any idea to get rid of the blank page here?
you can do Page.close() instead sending ^w
Or you can also delete/disable this line Page.url := "about:Blank"
, please read the documentation to understand all the methods and conditions
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by anhnha » 07 Dec 2022, 04:46

I had tried to distable Page.url := "about:Blank" but there is still a blank page opened as you can see in the code and image below.
image.png
image.png (54.01 KiB) Viewed 2148 times

Code: Select all

Chrome := new Rufaydium()
urls := ["https://www.autohotkey.com/boards/viewforum.php?f=4","https://chromedevtools.github.io/devtools-protocol","https://github.com/Xeo786/Rufaydium-Webdriver"]
Page := Chrome.NewSession()
for i, url  in urls
    Page.CDP.CreateTarget(url)

I also tried session:= Chrome.getSession(1) , Page.close(session) but it didn't work. It always closed the wrong tab or didn't close any tab.
I want to close the blank page instead.

Code: Select all

Chrome := new Rufaydium()
urls := ["https://www.autohotkey.com/boards/viewforum.php?f=4","https://chromedevtools.github.io/devtools-protocol","https://github.com/Xeo786/Rufaydium-Webdriver"]
Page := Chrome.NewSession()
Page.url := "about:Blank"
for i, url  in urls
    Page.CDP.CreateTarget(url)

session:= Chrome.getSession(1)
Page.close(session)

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 » 07 Dec 2022, 06:16

This will not create blank page

Code: Select all

Chrome := new Rufaydium()
urls := ["https://www.autohotkey.com/boards/viewforum.php?f=4","https://chromedevtools.github.io/devtools-protocol","https://github.com/Xeo786/Rufaydium-Webdriver"]
Page := Chrome.NewSession()
; Page.url := "about:Blank" ; this is how you disable line 
for i, url  in urls
    Page.CDP.CreateTarget(url)
please Read documentation for basic tasks

Code: Select all

/* ; this is wrong
session:= Chrome.getSession(1)
Page.close(session)
*/
Session:= Chrome.getSession(1)
Session.close()
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by anhnha » 07 Dec 2022, 16:14

Code: Select all

This will not create blank page
I'm not sure why you keep saying that it does not create blank page.
I did try that many times and it didn't work for me. I also I captured result that it still opened with a page called data; in my previous post.
image.png
image.png (39.21 KiB) Viewed 2100 times

Code: Select all

/* ; this is wrong
session:= Chrome.getSession(1)
Page.close(session)
*/
Session:= Chrome.getSession(1)
Session.close()
And this again does not work as well. I want to delete about:blank#blocked but all the suggestions so far sometimes delete the wrong tab or not delete any tab at all.
please Read documentation for basic tasks
I would be more than happy if this work but normally it does not as you don't give a complete example to show how it work so many times I get confused between pages/tabs/sessions and even sessions and Session.
I have been trying to read definitions in function definition as well.

So far none of the methods you said above works.
Does it work on your PC or just me?
I tried it on two PC but none of them work.
Here is the image showing that it does not work and error.
image.png
image.png (37.3 KiB) Viewed 2100 times
image.png
image.png (32.99 KiB) Viewed 2100 times
And another time, with exactly same code above, it deleted the wrong page. The blank page is still there.

Code: Select all

Session:= Chrome.getSessionByUrl("about:Blank")
Session.close()
Chrome.getSessionByUrl("about:Blank") works but I'm looing for a solution to not generate the blank page instead of just create and then remove.
That is why I asked if that blank page is required.
You can disable that line but no help, it created a different blank page.
Last edited by anhnha on 07 Dec 2022, 22:48, edited 1 time in total.

mora145
Posts: 57
Joined: 25 Jun 2022, 15:31

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by mora145 » 07 Dec 2022, 18:26

Xeo786 wrote:
07 Dec 2022, 02:25
mora145 wrote:
07 Dec 2022, 01:14
I am trying to do some scrolling in this window. I can't get it to scroll correctly but it's the screen behind me that moves. How can I do it?
Screenshot_81.jpg
Get all elements having innertext unfollow, now you can use element[x].focus it will automatically scroll to the element and focus that element
if you use New Scroll() it will scroll the stuff according to the mouse pointer location, therefore you also need to use New Mouse() to place the pointer to such a location so it gets the desired scrollbar act upon.

Thanks for your answer. I don't quite understand what element[x].focus should be used for, if New Mouse is going to be used to then click. New Mouse will click on the focus element? But you are supposed to be suggesting to use innertext in unfollow.

Post Reply

Return to “Scripts and Functions (v1)”