Page 18 of 31

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

Posted: 06 Sep 2022, 00:46
by Xeo786
ctech wrote:
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
Unhiding the chromedriver window produces the following message when trying to create the session:
image.png
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.
if you want to use an existing profile I suggest you make another one because if you are running a normal browser (using that specific profile) chrome Driver will not have the authority to read the profile, which is being used normally for security reasons. you need to close all chrome windows then try creating webdriver session to make it work.

OR

Make sure you have the "Profile 1" folder at UserDataDir location, you can create "Profile 1" if its not there using FileCreateDIR or pass "default" >> Chrome.capabilities.setUserProfile("Default") to load the default profile,

You can also pass custom userdatadir

Code: Select all

#Include Rufaydium.ahk
UserDataDir := a_scriptdir "\ChromeUserDATA\"
Profile := "Profile 1"

if !fileexist(UserDataDir) ; create dir if not there
	FilecreateDir, % UserDataDir
if !fileexist(UserDataDir Profile) ; create dir if not there
	FilecreateDir, % UserDataDir Profile
Chrome := new Rufaydium("chromedriver.exe")
Chrome.capabilities.setUserProfile(Profile, UserDataDir ) ; passing  custom userdatadir 
Page := Chrome.NewSession()
Page.Url := "https://www.autohotkey.com/"

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

Posted: 19 Sep 2022, 12:25
by hotkeyguy
Many thanks for all your efforts!

I'm an Firefox guy. Any news concerning Session.FRP (Firefox Remote Protocols)? Must inject JS code in my visited pages.

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

Posted: 25 Sep 2022, 04:17
by yousef_badr23
I am trying to get headless mode for chrome to work on my project (following updates on my amazon orders), but I wouldn't get many of the elements unless i turned headless mode off. I tried both

Code: Select all

browser.capabilities.HeadlessMode := True

and

Code: Select all

browser.capabilities.addArg(" --window-size=1920,1080 ")
			browser.capabilities.addArg(" --start-maximized ")
			browser.capabilities.addArg(" --headless ") 
			browser.capabilities.addArg(" --ignore-certificate-errors ")
			browser.capabilities.addArg(" --allow-running-insecure-content ") ;needed for headless
			browser.capabilities.addArg(" --disable-gpu ")
			browser.capabilities.addArg(" --user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36 ")
to no avail. After tinkering a bit and viewing the site html. I discovered an error in the headless mode Image (Please enable cookies & sign in, in case the preview doesn't work), while without the headless mode i can get all the elements I need.
How to fix this?
Thanks for this awesome library!

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

Posted: 25 Sep 2022, 07:14
by yousef_badr23
yousef_badr23 wrote:
25 Sep 2022, 04:17
I am trying to get headless mode for chrome to work on my project (following updates on my amazon orders), but I wouldn't get many of the elements unless i turned headless mode off. I tried both

Code: Select all

browser.capabilities.HeadlessMode := True

and

Code: Select all

browser.capabilities.addArg(" --window-size=1920,1080 ")
browser.capabilities.addArg(" --start-maximized ")
browser.capabilities.addArg(" --headless ") 
browser.capabilities.addArg(" --ignore-certificate-errors ")
browser.capabilities.addArg(" --allow-running-insecure-content ") ;needed for headless
browser.capabilities.addArg(" --disable-gpu ")
browser.capabilities.addArg(" --user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36 ")
to no avail. After tinkering a bit and viewing the site html. I discovered an error in the headless mode Image (Please enable cookies & sign in, in case the preview doesn't work), while without the headless mode i can get all the elements I need.
How to fix this?
Thanks for this awesome library!
Image
This is the html (document.queryselector(body).outerhtml) of the headless amazon page, I also tried other sites that didn't work with headless mode and I wasn't signed in in any of them in headless mode only.
I want to check these sites in the background without any popup or browser, is headless mode the only way(other than minimizing the browser)?

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

Posted: 10 Oct 2022, 23:14
by arimania
Sorry admin please delete the last 2 unapproved post, this is the revised post.

Hi i have a question, why the 'innerText' and 'textContent' NotWorking to get the value of second 'span', this use with ChromeDriver.
isnpect00000117014976.PNG
isnpect00000117014976.PNG (10.84 KiB) Viewed 3570 times

Code: Select all

<div class="price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl" data-purpose="course-price-text"><span class="udlite-sr-only">Current</span><span>Free</span></div>
i tried the possibilities, when using console on inspect element it show the value, but in rufaydium, not value at all.

Code: Select all

aa1 := Page.getElementsByClassName("price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].textContent
aa2 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl""]")[0].getElementsByTagName("span")[1].innerText
aa21 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].textContent
aa3 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl""]")[0].getElementsByTagName("span")[1].innerText
aa4 := Page.getElementsByClassName("price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].innerText
aa5 := Page.CDP.Evaluate("document.getElementsByClassName('price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl')[0].getElementsByTagName('span')[1].textContent;").value
MsgBox, aa2= %aa2% `r`n aa21=%aa21% `r`n aa3= %aa3% `r`n aa4 = %aa4% `r`n aa5= %aa5%
The Second, how to get the value of Page.GetTabs(), THIS also not showing any value. See the Full Code

Code: Select all

#SingleInstance Force
#Include Rufaydium.ahk
#Include CDP.ahk
Chrome := new Rufaydium("chromedriver.exe")

Page := Chrome.NewSession()
Page.CDP.Document()
TestWithIsLoading := 1 ;not working
;TestWithIsLoading := 0 ;working
Loop,
{
	if (Clipboard !="" && InStr(Clipboard, "foo")>0 )     
	{
		url_0 := Clipboard
		Page.Navigate(url_0)
		sleep, 1000
		historysaved := url_0 . "`r`n"
		FileAppend, url_0. "`r`n", D:\aarun2\AutohotkeyArea\Ruvaydium\Rufaydium-Webdriver-main\myhistory.txt
		;ini url dengan isi udemy link.
		url_1 := Page.getElementsByClassName("rh_button_wrapper")[0].getElementsByTagName("a")[0].href
		Page.getElementsByClassName("rh_button_wrapper")[0].getElementsByTagName("a")[0].click()
	    
		;What CODE to make sure not to close the last opened aka url_1 aka Second Tab but the just close  the First Tab
		;How to Make sure it is not closed the tab with url_1 because of the switchicng time/Loading not always in 1 seconds, how to make it dynamically.
		Page.SwitchbyURL(url_0)
		MsgBox, % Page.GetTabs()        ;<=== this also empty
		MsgBox, % Page.GetTabs().value  ;<=== this also empty
		Sleep 1000
		Page.close()
 

		aa1 := Page.getElementsByClassName("price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].textContent
        aa2 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl""]")[0].getElementsByTagName("span")[1].innerText
		aa21 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].textContent
		aa3 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl""]")[0].getElementsByTagName("span")[1].innerText
		aa4 := Page.getElementsByClassName("price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].innerText
		aa5 := Page.CDP.Evaluate("document.getElementsByClassName('price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl')[0].getElementsByTagName('span')[1].textContent;").value
		aa51 := Page.CDP.Evaluate("document.getElementsByClassName('price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl')[0].getElementsByTagName('span')[1].textContent;").value
		
		MsgBox, aa1= %aa1% `r`n aa2= %aa2% `r`n aa21=%aa21% `r`n aa3= %aa3% `r`n aa4 = %aa4% `r`n aa5= %aa5% `r`n aa51= %aa51%
		
		if ( %aa2% == "Free" ){
			
			If TestWithIsLoading ;not working
			  {
				;this forum user said this not working so just make it empty
			  }
			else ;working
			  {
				;Wait until Button "Free" is available
				MyButton := ""
				While !IsObject(MyButton)
				  {
					sleep, 200
					MyButton := Page.findelement(by.linktext,"Add to cart") ;Partial link text
					MyButton.click() ;Click on ATC Button
				  }
			  }
		;Page.getElementsByClassName("udlite-btn udlite-btn-large udlite-btn-brand udlite-heading-md add-to-cart")[0].click()
		
		}else{
		MsgBox, 64, Var ab2 Contents, %Clipboard% `r`n`r`nthis will closed on 3 seconds, 5
	    }
		
		
		Pause	
    } else {
		Sleep, 2000
	}
}
return

^b::
InputBox, asb, Masukkan Url, 
if (asb !=""){
	if (InStr(asb, "tutorialbar")>0 =){
		Page.Navigate(asb)
	}
}
return


^m::
Chrome.QuitAllSessions() ; close all session 
Chrome.Driver.Exit() ; then exits driver
return

^d::Pause
Return

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

Posted: 11 Oct 2022, 01:19
by Xeo786
arimania wrote:
10 Oct 2022, 23:14
Sorry admin please delete the last 2 unapproved post, this is the revised post.

Hi i have a question, why the 'innerText' and 'textContent' NotWorking to get the value of second 'span', this use with ChromeDriver.
isnpect00000117014976.PNG

Code: Select all

<div class="price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl" data-purpose="course-price-text"><span class="udlite-sr-only">Current</span><span>Free</span></div>
i tried the possibilities, when using console on inspect element it show the value, but in rufaydium, not value at all.

Code: Select all

aa1 := Page.getElementsByClassName("price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].textContent
aa2 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl""]")[0].getElementsByTagName("span")[1].innerText
aa21 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].textContent
aa3 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl""]")[0].getElementsByTagName("span")[1].innerText
aa4 := Page.getElementsByClassName("price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].innerText
aa5 := Page.CDP.Evaluate("document.getElementsByClassName('price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl')[0].getElementsByTagName('span')[1].textContent;").value
MsgBox, aa2= %aa2% `r`n aa21=%aa21% `r`n aa3= %aa3% `r`n aa4 = %aa4% `r`n aa5= %aa5%
The Second, how to get the value of Page.GetTabs(), THIS also not showing any value. See the Full Code

Code: Select all

#SingleInstance Force
#Include Rufaydium.ahk
#Include CDP.ahk
Chrome := new Rufaydium("chromedriver.exe")

Page := Chrome.NewSession()
Page.CDP.Document()
TestWithIsLoading := 1 ;not working
;TestWithIsLoading := 0 ;working
Loop,
{
	if (Clipboard !="" && InStr(Clipboard, "foo")>0 )     
	{
		url_0 := Clipboard
		Page.Navigate(url_0)
		sleep, 1000
		historysaved := url_0 . "`r`n"
		FileAppend, url_0. "`r`n", D:\aarun2\AutohotkeyArea\Ruvaydium\Rufaydium-Webdriver-main\myhistory.txt
		;ini url dengan isi udemy link.
		url_1 := Page.getElementsByClassName("rh_button_wrapper")[0].getElementsByTagName("a")[0].href
		Page.getElementsByClassName("rh_button_wrapper")[0].getElementsByTagName("a")[0].click()
	    
		;What CODE to make sure not to close the last opened aka url_1 aka Second Tab but the just close  the First Tab
		;How to Make sure it is not closed the tab with url_1 because of the switchicng time/Loading not always in 1 seconds, how to make it dynamically.
		Page.SwitchbyURL(url_0)
		MsgBox, % Page.GetTabs()        ;<=== this also empty
		MsgBox, % Page.GetTabs().value  ;<=== this also empty
		Sleep 1000
		Page.close()
 

		aa1 := Page.getElementsByClassName("price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].textContent
        aa2 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl""]")[0].getElementsByTagName("span")[1].innerText
		aa21 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].textContent
		aa3 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl""]")[0].getElementsByTagName("span")[1].innerText
		aa4 := Page.getElementsByClassName("price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].innerText
		aa5 := Page.CDP.Evaluate("document.getElementsByClassName('price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl')[0].getElementsByTagName('span')[1].textContent;").value
		aa51 := Page.CDP.Evaluate("document.getElementsByClassName('price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl')[0].getElementsByTagName('span')[1].textContent;").value
		
		MsgBox, aa1= %aa1% `r`n aa2= %aa2% `r`n aa21=%aa21% `r`n aa3= %aa3% `r`n aa4 = %aa4% `r`n aa5= %aa5% `r`n aa51= %aa51%
		
		if ( %aa2% == "Free" ){
			
			If TestWithIsLoading ;not working
			  {
				;this forum user said this not working so just make it empty
			  }
			else ;working
			  {
				;Wait until Button "Free" is available
				MyButton := ""
				While !IsObject(MyButton)
				  {
					sleep, 200
					MyButton := Page.findelement(by.linktext,"Add to cart") ;Partial link text
					MyButton.click() ;Click on ATC Button
				  }
			  }
		;Page.getElementsByClassName("udlite-btn udlite-btn-large udlite-btn-brand udlite-heading-md add-to-cart")[0].click()
		
		}else{
		MsgBox, 64, Var ab2 Contents, %Clipboard% `r`n`r`nthis will closed on 3 seconds, 5
	    }
		
		
		Pause	
    } else {
		Sleep, 2000
	}
}
return

^b::
InputBox, asb, Masukkan Url, 
if (asb !=""){
	if (InStr(asb, "tutorialbar")>0 =){
		Page.Navigate(asb)
	}
}
return


^m::
Chrome.QuitAllSessions() ; close all session 
Chrome.Driver.Exit() ; then exits driver
return

^d::Pause
Return
use ' inside ", querySelector will return with frist element and querySelectorAll will return with array, you are using "[0]" i.e. QuerySelector(query)[0] which is wrong

Code: Select all

aa2 := Page.QuerySelector("[class='price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl']").getElementsByTagName("span")[1].innerText
use innerText on the main element to get whole innertext from sub-elements, the same goes for textContent

Code: Select all

e := Page.QuerySelector("[class='price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl']")
msgbox, % e.innerText
msgbox, % e.textContent

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

Posted: 11 Oct 2022, 01:35
by Xeo786
yousef_badr23 wrote:
25 Sep 2022, 07:14
yousef_badr23 wrote:
25 Sep 2022, 04:17
I am trying to get headless mode for chrome to work on my project (following updates on my amazon orders), but I wouldn't get many of the elements unless i turned headless mode off. I tried both

Code: Select all

browser.capabilities.HeadlessMode := True

and

Code: Select all

browser.capabilities.addArg(" --window-size=1920,1080 ")
browser.capabilities.addArg(" --start-maximized ")
browser.capabilities.addArg(" --headless ") 
browser.capabilities.addArg(" --ignore-certificate-errors ")
browser.capabilities.addArg(" --allow-running-insecure-content ") ;needed for headless
browser.capabilities.addArg(" --disable-gpu ")
browser.capabilities.addArg(" --user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36 ")
to no avail. After tinkering a bit and viewing the site html. I discovered an error in the headless mode Image (Please enable cookies & sign in, in case the preview doesn't work), while without the headless mode i can get all the elements I need.
How to fix this?
Thanks for this awesome library!
Image
This is the html (document.queryselector(body).outerhtml) of the headless amazon page, I also tried other sites that didn't work with headless mode and I wasn't signed in in any of them in headless mode only.
I want to check these sites in the background without any popup or browser, is headless mode the only way(other than minimizing the browser)?
I am sure, You need to try the different combinations of chrome CMD switches, some switches do not work together and some switches disable a bunch of other abilities you need to enable by using more switches, so you need to study and learn about switches, I have dived into these but I need to read all those details again even I might not able to resolve your issue.

I never tried but you can use Autohotkey winhide to hide the chrome, instead using headless mode, I never tried that, I do not know what issue it would cause to Web driver behaviour

Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)

Posted: 18 Oct 2022, 02:33
by yousef_badr23
Xeo786 wrote:
11 Oct 2022, 01:35
yousef_badr23 wrote:
25 Sep 2022, 07:14
yousef_badr23 wrote:
25 Sep 2022, 04:17
I am trying to get headless mode for chrome to work on my project (following updates on my amazon orders), but I wouldn't get many of the elements unless i turned headless mode off. I tried both

Code: Select all

browser.capabilities.HeadlessMode := True

and

Code: Select all

browser.capabilities.addArg(" --window-size=1920,1080 ")
browser.capabilities.addArg(" --start-maximized ")
browser.capabilities.addArg(" --headless ") 
browser.capabilities.addArg(" --ignore-certificate-errors ")
browser.capabilities.addArg(" --allow-running-insecure-content ") ;needed for headless
browser.capabilities.addArg(" --disable-gpu ")
browser.capabilities.addArg(" --user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36 ")
to no avail. After tinkering a bit and viewing the site html. I discovered an error in the headless mode Image (Please enable cookies & sign in, in case the preview doesn't work), while without the headless mode i can get all the elements I need.
How to fix this?
Thanks for this awesome library!
Image
This is the html (document.queryselector(body).outerhtml) of the headless amazon page, I also tried other sites that didn't work with headless mode and I wasn't signed in in any of them in headless mode only.
I want to check these sites in the background without any popup or browser, is headless mode the only way(other than minimizing the browser)?
I am sure, You need to try the different combinations of chrome CMD switches, some switches do not work together and some switches disable a bunch of other abilities you need to enable by using more switches, so you need to study and learn about switches, I have dived into these but I need to read all those details again even I might not able to resolve your issue.

I never tried but you can use Autohotkey winhide to hide the chrome, instead using headless mode, I never tried that, I do not know what issue it would cause to Web driver behaviour
I figured it out. Headless mode in chrome does not save cookies. It works just fine in firefox, with no need to log in again.

Re: Rufaydium WebDriver 1.7.1 (no selenium/websocket)

Posted: 19 Oct 2022, 15:45
by separateattention
Hi Xeo, first, thanks for your amazing work.

I have a question, I´m trying to use the "capabilities.setUserProfile", but can't make it work. If I set "MSEdge.capabilities.setUserProfile("Default")", I get the following error:

Image

I'm not using the default profile at all, no open tabs.

If I delete the line, it works without issue but it will always create a temp profile in "C:\Users\...\AppData\Local\Temp\scoped_dir4784_1929702658\Default" for example.

Here's my code:

Code: Select all

#Include %A_ScriptDir%\Lib\
#Include Rufaydium.ahk

MSEdge := new Rufaydium("msedgedriver.exe")
MSEdge.capabilities.setUserProfile("Default")

WB := MSEdge.NewSession()
WB.Navigate("http://...")
Return

Re: Rufaydium WebDriver 1.7.1 (no selenium/websocket)

Posted: 21 Oct 2022, 07:16
by Xeo786
separateattention wrote:
19 Oct 2022, 15:45
Hi Xeo, first, thanks for your amazing work.

I have a question, I´m trying to use the "capabilities.setUserProfile", but can't make it work. If I set "MSEdge.capabilities.setUserProfile("Default")", I get the following error:

Image

I'm not using the default profile at all, no open tabs.

If I delete the line, it works without issue but it will always create a temp profile in "C:\Users\...\AppData\Local\Temp\scoped_dir4784_1929702658\Default" for example.

Here's my code:

Code: Select all

#Include %A_ScriptDir%\Lib\
#Include Rufaydium.ahk

MSEdge := new Rufaydium("msedgedriver.exe")
MSEdge.capabilities.setUserProfile("Default")

WB := MSEdge.NewSession()
WB.Navigate("http://...")
Return
You might need to provide user data dir as well,

Code: Select all

MSEdge.capabilities.setUserProfile("Default", appdata "\Microsoft\Edge\User Data") ; 
Right now default userdatadir in rufaydium,

Code: Select all

userDataDir := StrReplace(A_AppData, "\Roaming") "\Local\Microsoft\Edge\User Data
I would like to know msedge's default userdatadir as I am on win7 without msedge right now.

Re: Rufaydium WebDriver 1.7.1 (no selenium/websocket)

Posted: 21 Oct 2022, 14:50
by separateattention
Xeo786 wrote:
21 Oct 2022, 07:16
separateattention wrote:
19 Oct 2022, 15:45
Hi Xeo, first, thanks for your amazing work.

I have a question, I´m trying to use the "capabilities.setUserProfile", but can't make it work. If I set "MSEdge.capabilities.setUserProfile("Default")", I get the following error:

Image

I'm not using the default profile at all, no open tabs.

If I delete the line, it works without issue but it will always create a temp profile in "C:\Users\...\AppData\Local\Temp\scoped_dir4784_1929702658\Default" for example.

Here's my code:

Code: Select all

#Include %A_ScriptDir%\Lib\
#Include Rufaydium.ahk

MSEdge := new Rufaydium("msedgedriver.exe")
MSEdge.capabilities.setUserProfile("Default")

WB := MSEdge.NewSession()
WB.Navigate("http://...")
Return
You might need to provide user data dir as well,

Code: Select all

MSEdge.capabilities.setUserProfile("Default", appdata "\Microsoft\Edge\User Data") ; 
Right now default userdatadir in rufaydium,

Code: Select all

userDataDir := StrReplace(A_AppData, "\Roaming") "\Local\Microsoft\Edge\User Data
I would like to know msedge's default userdatadir as I am on win7 without msedge right now.
Sadly it didn't work but I tested the same code with chrome and there's no problem there, so it's definitely something about edge, I tested a couple changes without luck.

Edge default userdatadir is "C:\Users\...\AppData\Local\Microsoft\Edge\User Data\Default".

A detail that I skipped and could help is that, after the error, Edge does open in the correct profile but there´s no session attached to it.

Re: Rufaydium WebDriver 1.7.1 (no selenium/websocket)

Posted: 27 Oct 2022, 19:47
by hotcheesesoup
@Xeo786

Would it be possible to prevent Chromedriver from closing when I close the active tab, but I have multiple tabs open?

Could it instead activate the next tab in the stack, or activate ANY existing tab in the Session instead of immediately closing?

Thanks!
-HCS

Re: Rufaydium WebDriver 1.7.1 (no selenium/websocket)

Posted: 31 Oct 2022, 01:04
by Xeo786
hotcheesesoup wrote:
27 Oct 2022, 19:47
@Xeo786

Would it be possible to prevent Chromedriver from closing when I close the active tab, but I have multiple tabs open?

Could it instead activate the next tab in the stack, or activate ANY existing tab in the Session instead of immediately closing?

Thanks!
-HCS
There were window handling issues with the last update, I was trying to eliminate tab/Window activating every time when we get access to any tab,
but at least now it does not activate all tabs one by one like previously, but in .close() caused window handling bug, the window handling bug has been fixed in the latest unreleased update.

Re: Rufaydium WebDriver 1.7.1 (no selenium/websocket)

Posted: 31 Oct 2022, 01:08
by hotcheesesoup
OK cool! Looking forward to the next update then!

I swear it was running fine until Chromedriver updated last week. Now it is kind of wonky.

Re: Rufaydium WebDriver 1.7.1 (no selenium/websocket)

Posted: 31 Oct 2022, 02:06
by Xeo786
hotcheesesoup wrote:
31 Oct 2022, 01:08
OK cool! Looking forward to the next update then!
Do not wait for the next release, Rufaydium is updated if you still face that issue, please point me to what method is causing the session to close.
hotcheesesoup wrote:
31 Oct 2022, 01:08
I swear it was running fine until Chromedriver updated last week. Now it is kind of wonky.
Yeah I notice that after the driver update, Before, when we close any chrome tab, using Session.close() it closes it then returns with the window ID of the active tab,
But now it returns with an array of all the tabs window ID, and now it's up to us to choose which window we want to switch, and I noticed
it is always the last index in the array that is the active tab after closer, so did this

Re: Rufaydium WebDriver 1.7.1 (no selenium/websocket)

Posted: 02 Nov 2022, 11:02
by separateattention
separateattention wrote:
21 Oct 2022, 14:50
Xeo786 wrote:
21 Oct 2022, 07:16
separateattention wrote:
19 Oct 2022, 15:45
Hi Xeo, first, thanks for your amazing work.

I have a question, I´m trying to use the "capabilities.setUserProfile", but can't make it work. If I set "MSEdge.capabilities.setUserProfile("Default")", I get the following error:

Image

I'm not using the default profile at all, no open tabs.

If I delete the line, it works without issue but it will always create a temp profile in "C:\Users\...\AppData\Local\Temp\scoped_dir4784_1929702658\Default" for example.

Here's my code:

Code: Select all

#Include %A_ScriptDir%\Lib\
#Include Rufaydium.ahk

MSEdge := new Rufaydium("msedgedriver.exe")
MSEdge.capabilities.setUserProfile("Default")

WB := MSEdge.NewSession()
WB.Navigate("http://...")
Return
You might need to provide user data dir as well,

Code: Select all

MSEdge.capabilities.setUserProfile("Default", appdata "\Microsoft\Edge\User Data") ; 
Right now default userdatadir in rufaydium,

Code: Select all

userDataDir := StrReplace(A_AppData, "\Roaming") "\Local\Microsoft\Edge\User Data
I would like to know msedge's default userdatadir as I am on win7 without msedge right now.
Sadly it didn't work but I tested the same code with chrome and there's no problem there, so it's definitely something about edge, I tested a couple changes without luck.

Edge default userdatadir is "C:\Users\...\AppData\Local\Microsoft\Edge\User Data\Default".

A detail that I skipped and could help is that, after the error, Edge does open in the correct profile but there´s no session attached to it.
@Xeo786 any idea? I've tried a lot but this is beyond me right now

Re: Rufaydium WebDriver 1.7.1 (no selenium/websocket)

Posted: 03 Nov 2022, 05:37
by Xeo786
separateattention wrote:
02 Nov 2022, 11:02
@Xeo786 any idea? I've tried a lot but this is beyond me right now
Just fixed a bug in loading User profile, there are a few things you need to take care.
1) make sure Edge is running and using that profile you want to access with webdriver, profile dir already in use will cause webdriver error
2) if you somehow run MS edge with webdriver while profile was already in use webdriver will crash, you need to kill all MS edge process and Runtime breaker processes, to make MS Edge Webdriver work
3) edge://profile-internals/ run this URL to check Profile DIR location on edge, just ignore Local Profile Name use actual Profile DIR name from profile path

here is example
Spoiler

Re: Rufaydium WebDriver 1.7.1 (no selenium/websocket)

Posted: 03 Nov 2022, 17:29
by separateattention
Xeo786 wrote:
03 Nov 2022, 05:37
separateattention wrote:
02 Nov 2022, 11:02
@Xeo786 any idea? I've tried a lot but this is beyond me right now
Just fixed a bug in loading User profile, there are a few things you need to take care.
1) make sure Edge is running and using that profile you want to access with webdriver, profile dir already in use will cause webdriver error
2) if you somehow run MS edge with webdriver while profile was already in use webdriver will crash, you need to kill all MS edge process and Runtime breaker processes, to make MS Edge Webdriver work
3) edge://profile-internals/ run this URL to check Profile DIR location on edge, just ignore Local Profile Name use actual Profile DIR name from profile path

here is example
Spoiler
Thanks a lot Xeo, now it's working.

Re: Rufaydium WebDriver 1.7.1 (no selenium/websocket)

Posted: 04 Nov 2022, 07:42
by cz_luckyluke99
separateattention wrote:
03 Nov 2022, 17:29
Xeo786 wrote:
03 Nov 2022, 05:37
separateattention wrote:
02 Nov 2022, 11:02
@Xeo786 any idea? I've tried a lot but this is beyond me right now
Just fixed a bug in loading User profile, there are a few things you need to take care.
1) make sure Edge is running and using that profile you want to access with webdriver, profile dir already in use will cause webdriver error
2) if you somehow run MS edge with webdriver while profile was already in use webdriver will crash, you need to kill all MS edge process and Runtime breaker processes, to make MS Edge Webdriver work
3) edge://profile-internals/ run this URL to check Profile DIR location on edge, just ignore Local Profile Name use actual Profile DIR name from profile path

here is example
Spoiler
Thanks a lot Xeo, now it's working.
Hi all,

what helped me with profile loading:

MSEdge:= new Rufaydium("msedgedriver.exe","--port=9516")
MSEdge.capabilities.addArg("--no-sandbox")
MSEdge.capabilities.addArg("--disable-dev-shm-usage")
MSEdge.capabilities.setUserProfile("Default")

Re: Rufaydium WebDriver 1.7.1 (no selenium/websocket)

Posted: 04 Nov 2022, 08:24
by Xeo786
cz_luckyluke99 wrote:
04 Nov 2022, 07:42
Hi all,

what helped me with profile loading:

MSEdge:= new Rufaydium("msedgedriver.exe","--port=9516")
MSEdge.capabilities.addArg("--no-sandbox")
MSEdge.capabilities.addArg("--disable-dev-shm-usage")
MSEdge.capabilities.setUserProfile("Default")
it working for for me, make sure browser is updated, and Rufaydium downloading msedgedriver.exe into a_scripdir, you can also download msedgedriver.exe manually

Code: Select all

MSEdge:= new Rufaydium("msedgedriver.exe","--port=9516")
MSEdge.capabilities.addArg("--no-sandbox")
MSEdge.capabilities.addArg("--disable-dev-shm-usage")
MSEdge.capabilities.setUserProfile("Default")

Page := MSEdge.NewSession() ; to create session
Page.url := "https://www.autohotkey.com/boards/" ; to navigate url

msgbox, press ok to close all sessions and exit
MSEdge.QuitAllSessions() ; close all session 
MSEdge.Driver.Exit() ; then exits driver
msgbox, all session closed and Driver Exitted