Page 27 of 31

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 15 Mar 2023, 09:32
by yousef_badr23
Is there a way to disable headless mode without starting a new browser object/ restarting the script?
I want to be able to fix login trouble / captcha if they occur then hide the window again, but keep headless mode as the default since errors like captcha are rare

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 17 Mar 2023, 16:18
by Tremzoff
First: Thanks for your efforts to give us Rufaydium, Xeo786!
Question: I want to detect if an object has been clicked and if so, trigger an action. E.g. a message box "Element was clicked". Can this also be done with Rufaydium? I have not found a solution yet. Any advice would be greatly appreciated.

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 21 Mar 2023, 19:41
by Tremzoff
Tremzoff wrote:
17 Mar 2023, 16:18
First: Thanks for your efforts to give us Rufaydium, Xeo786!
Question: I want to detect if an object has been clicked and if so, trigger an action. E.g. a message box "Element was clicked". Can this also be done with Rufaydium? I have not found a solution yet. Any advice would be greatly appreciated.
I solved it myself:

Code: Select all

Session.CDP.Evaluate("let value = 'no click'; const path = document.querySelector(""YOUR SELECTOR""); path.onclick = function breakLoop(){ value = 'clicked'; }")

Loop {

	if (Session.ExecuteSync("return value")="clicked")
	{
		msgbox, Clicked!
		Session.ExecuteSync("value='kein klick'")
	}
    Sleep 100
}
Instead of "YOUR SELECTOR" simply put in your own selector. Just inspect the element and copy it's JS Path. To inspect, right-click an element on a page and select Inspect.
I hope this will be helpful for somebody ;)

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 26 Mar 2023, 06:51
by JerryMaguire
I use Vivaaldi Browser, session.NewTab() is working, but tab focus not work, SwitchTab(2) not work

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 27 Mar 2023, 05:27
by Xeo786
JerryMaguire wrote:
26 Mar 2023, 06:51
I use Vivaaldi Browser, session.NewTab() is working, but tab focus not work, SwitchTab(2) not work
I want to see Tab id

Code: Select all

; Session.SwitchTab(1)  ; if this not working 
session.NewTab()
msgbox, % Session.currentTab ; this is how you get Tab id

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 27 Mar 2023, 05:29
by Xeo786
Tremzoff wrote:
21 Mar 2023, 19:41
I solved it myself:
You could also use Session.ExecuteSync(JS) to pass any JS function

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 28 Mar 2023, 11:17
by magusneo
Can Rufaydium pass the Cloudflare bot checking?
check this site:https://nowsecure.nl//
chrome can't visit it if starting with chromedriver.exe.

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 28 Mar 2023, 11:34
by JerryMaguire
I want to open two browsers (Chrome and Brave) in one .ahk via Rufaydium WebDriver, is it possible?

In fact, I want to open 2 Chromium (Chrome and Brave) and 1 MSEdge, but currently only Chrome and MSEdge can be successfully opened

Chrome and MSEdge is working

Code: Select all

#Include D:\Rufaydium-Webdriver\Rufaydium.ahk

MyProfileDir := "E:\Profile_Dir\"

Chrome := new Rufaydium()

Chrome.capabilities.setUserProfile("Default") ; can use Default user
Chrome.capabilities.setUserProfile("Profile 1", MyProfileDir)      ; for Brave

Session1 := Chrome.NewSession()

Chrome.capabilities.Addextensions(extensionloaction) ; will load extensions
Chrome.capabilities.AddexcludeSwitches("enable-automation") ; will load Chrome without default args
Chrome.capabilities.DebugPort(9255) ; will change port for debuggerAddress

Session1.Navigate("http://www.google.com.tw/")
Session1.querySelector("body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input").Focus()
Session1.querySelector("body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input").SendKey("Rufaydium")
Session1.querySelector("body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.FPdoLc.lJ9FBc > center > input.gNO89b").Click()

Session1.NewTab()   

Session1.Navigate("https://www.autohotkey.com/")

Chrome.Driver.Exit()

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

;MSEdge.capabilities.Addextensions(extensionloaction) ; will load extensions
;MSEdge.capabilities.AddexcludeSwitches("enable-automation") ; will load Chrome without default args
;MSEdge.capabilities.DebugPort(9256) ; will change port for debuggerAddress

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

MSEdge.Driver.Exit()

ExitApp
This is my code,Chrome and Brave not working

Code: Select all

#Include D:\Rufaydium-Webdriver\Rufaydium.ahk

MyProfileDir := "D:\Profile_Dir\"

Chrome := new Rufaydium()

Chrome.capabilities.setUserProfile("Default") ; can use Default user
Chrome.capabilities.setUserProfile("Profile 1", MyProfileDir)      ; for Brave

Session1 := Chrome.NewSession()

Chrome.capabilities.Addextensions(extensionloaction) ; will load extensions
Chrome.capabilities.AddexcludeSwitches("enable-automation") ; will load Chrome without default args
Chrome.capabilities.DebugPort(9255) ; will change port for debuggerAddress

Session1.Navigate("http://www.google.com.tw/")
Session1.querySelector("body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input").Focus()
Session1.querySelector("body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input").SendKey("Rufaydium")
Session1.querySelector("body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.FPdoLc.lJ9FBc > center > input.gNO89b").Click()

Session1.NewTab()   

Session1.Navigate("https://www.autohotkey.com/")

Chrome.Driver.Exit()

Brave:= new Rufaydium("chromedriver.exe")
;Brave:= new Rufaydium("Bravedriver.exe","--port=9516")
Brave.capabilities.addArg("--no-sandbox")
Brave.capabilities.addArg("--disable-dev-shm-usage")
Brave.capabilities.setUserProfile("Profile2")

Brave.capabilities.Addextensions(extensionloaction) ; will load extensions
Brave.capabilities.AddexcludeSwitches("enable-automation") ; will load Chrome without default args
;Brave.capabilities.DebugPort(9256) ; will change port for debuggerAddress


Page := Brave.NewSession("C:\Users\Conan_PC\AppData\Local\BraveSoftware\Brave-Browser\Application\brave.exe") ; to create session
Page.url := "https://www.autohotkey.com/boards/" ; to navigate url

Brave.Driver.Exit()

ExitApp

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 28 Mar 2023, 22:22
by JerryMaguire
@Xeo786

Regarding Chrome.capabilities.Addextensions(extensionloaction), I just found out that my understanding of "extensionloaction" was wrong

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 28 Mar 2023, 23:44
by Xeo786
magusneo wrote:
28 Mar 2023, 11:17
Can Rufaydium pass the Cloudflare bot checking?
check this site:https://nowsecure.nl//
chrome can't visit it if starting with chromedriver.exe.
yes :shh: here

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 28 Mar 2023, 23:59
by Xeo786
JerryMaguire wrote:
28 Mar 2023, 11:34
I want to open two browsers (Chrome and Brave) in one .ahk via Rufaydium WebDriver, is it possible?

In fact, I want to open 2 Chromium (Chrome and Brave) and 1 MSEdge, but currently only Chrome and MSEdge can be successfully opened
the issue is Brave uses chromedriver, we cannot rename driver.exe because I didn't wrote Rufaydium that way.
yes, You need two chromedriver.exe from different location.

Code: Select all

#include Rufaydium.ahk 
ChromeF := A_ScriptDir "\ChromeDriver"
if !FileExist(ChromeF)
    FileCreateDir, % ChromeF

BraveF := A_ScriptDir "\BraveDriver"
if !FileExist(BraveF)
    FileCreateDir, % BraveF

Chrome := new Rufaydium(ChromeF "\ChromeDriver.exe") ; default port 9515
ChromeSession := Chrome.NewSession()

Brave := new Rufaydium(BraveF "\ChromeDriver.exe","--port=9514")
BraveExe := "here put tyhe location of brave broswer executeabls"
BraveSession := Brave.NewSession(BraveExe)
You were able to run Edge with chrome because they got their own driver, both chromemium based
but Brave is Chrome Based it uses chromedriver

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 29 Mar 2023, 00:37
by magusneo
Xeo786 wrote:
28 Mar 2023, 23:44
magusneo wrote:
28 Mar 2023, 11:17
Can Rufaydium pass the Cloudflare bot checking?
check this site:https://nowsecure.nl//
chrome can't visit it if starting with chromedriver.exe.
yes :shh: here
Thank you.It works like a charm. :bravo: :bravo:

Code: Select all

chrome.Capabilities.addArg("--disable-blink-features=AutomationControlled")

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 29 Mar 2023, 04:27
by JerryMaguire
Xeo786 wrote:
28 Mar 2023, 23:59
JerryMaguire wrote:
28 Mar 2023, 11:34
I want to open two browsers (Chrome and Brave) in one .ahk via Rufaydium WebDriver, is it possible?

In fact, I want to open 2 Chromium (Chrome and Brave) and 1 MSEdge, but currently only Chrome and MSEdge can be successfully opened
the issue is Brave uses chromedriver, we cannot rename driver.exe because I didn't wrote Rufaydium that way.
yes, You need two chromedriver.exe from different location.

Code: Select all

#include Rufaydium.ahk 
ChromeF := A_ScriptDir "\ChromeDriver"
if !FileExist(ChromeF)
    FileCreateDir, % ChromeF

BraveF := A_ScriptDir "\BraveDriver"
if !FileExist(BraveF)
    FileCreateDir, % BraveF

Chrome := new Rufaydium(ChromeF "\ChromeDriver.exe") ; default port 9515
ChromeSession := Chrome.NewSession()

Brave := new Rufaydium(BraveF "\ChromeDriver.exe","--port=9514")
BraveExe := "here put tyhe location of brave broswer executeabls"
BraveSession := Brave.NewSession(BraveExe)
You were able to run Edge with chrome because they got their own driver, both chromemium based
but Brave is Chrome Based it uses chromedriver
thank you so much
Through your demonstration, which is also the most important part, plus the path of webdriver.exe, this part is something I have always wanted to do but couldn’t figure it out. I can let Chromium-based browsers use their own versions and open them in the same ahk multiple browsers

Here is my code, it works

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#Include D:\Rufaydium-Webdriver\Rufaydium.ahk

BraveProfileDir := "D:\Profile_Dir\Brave\User Data\"
MSEdgeProfileDir := "D:\Profile_Dir\Edge\User Data\"
ChromeBraveProfileDir := "D:\Profile_Dir\Chrome\User Data\"
IronProfileDir := "D:\Profile_Dir\SRWareIron\User Data\"

Brave_Driver_File := A_ScriptDir "\WebDriver\Brave"
Brave_Exe_File := "C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe"
Chrome_Driver_File := A_ScriptDir "\WebDriver\Chrome"
Iron_Driver_File := A_ScriptDir "\WebDriver\Iron"
Iron_Exe_File := "C:\Program Files\SRWare Iron (64-Bit)\chrome.exe"


Brave_Driver := new Rufaydium(Brave_Driver_File "\ChromeDriver.exe","--port=9514")
Brave_Driver.capabilities.setUserProfile("Default", BraveProfileDir) ; can use Default user

Brave_Session := Brave_Driver.NewSession(Brave_Exe_File)


Brave_Session.Navigate("http://www.google.com.tw/")
Brave_Session.querySelector("body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input").Focus()
Brave_Session.querySelector("body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input").SendKey("Rufaydium")
Brave_Session.querySelector("body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.FPdoLc.lJ9FBc > center > input.gNO89b").Click()

Brave_Session.NewTab()   

Brave_Session.Navigate("https://www.autohotkey.com/")


Chrome_Driver:= new Rufaydium()
Chrome_Driver.capabilities.setUserProfile("Default", ChromeBraveProfileDir)     


Chrome_Session := Chrome_Driver.NewSession() ; to create session
Chrome_Session.url := "https://www.hinet.net" ; to navigate url



MSEdge_Driver:= new Rufaydium("msedgedriver")   ;,"--port=9516")
MSEdge_Driver.capabilities.setUserProfile("Profile 3", MSEdgeProfileDir)


MSEdge_Session := MSEdge_Driver.NewSession() ; to create session
MSEdge_Session.url := "https://shopee.tw/" ; to navigate url


Iron_Driver := new Rufaydium(Iron_Driver_File "\ChromeDriver.exe","--port=9519")
Iron_Driver.capabilities.setUserProfile("Default", IronProfileDir) ; can use Default user

Iron_Session := Iron_Driver.NewSession(Iron_Exe_File)

Iron_Session.Navigate("http://www.google.com.tw/")
Iron_Session.querySelector("body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input").Focus()
Iron_Session.querySelector("body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input").SendKey("Rufaydium")
Iron_Session.querySelector("body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.FPdoLc.lJ9FBc > center > input.gNO89b").Click()

Iron_Session.NewTab()   

Iron_Session.Navigate("https://www.autohotkey.com/")

ExitApp

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 29 Mar 2023, 06:19
by Xeo786
JerryMaguire wrote:
28 Mar 2023, 22:22
@Xeo786

Regarding Chrome.capabilities.Addextensions(extensionloaction), I just found out that my understanding of "extensionloaction" was wrong
btw I just noticed Extension location should be base64
image.png
image.png (8.12 KiB) Viewed 3571 times
So I made few changes in capabilities to conver exension path to base64 but still I am unable to create session with addextension, Error says cannot unzip

Code: Select all

Chrome := new Rufaydium()
extension := "C:\Users\irfan.exportho\Desktop\ChatGPT\extension_1_1_0_0.crx"
Chrome.Capabilities.Addextensions(extension) ; << cause error for me may be I am not doing proper base64 or I do not know the correct formate
page := Chrome.NewSession()
page.url := "google.com"
but you can Run 1 uncompiled extesnion this way

Code: Select all

#include Rufaydium.ahk 
Chrome := new Rufaydium()
UncomprassedExtFolder :=  a_desktop "\ChatGPT\chatgpt"
Chrome.Capabilities.AddCustomExtension(UncomprassedExtFolder) ; make sure you are pass folder not the extension
page := Chrome.NewSession()
page.url := "google.com"

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 30 Mar 2023, 00:19
by Milchmann
Hello Xeo786,


I pulled down your latest version. Since then I have an error that the current tab is no longer recognised by Chrome. Only the window that is active at the start is recognised. If I change the tab, the first recognised window remains active.

Code: Select all

; new
if( this.name != "geckodriver" )
			this.Switch(this.Detail()[1].id ) ; First id always Current Handle
and old

Code: Select all

if( this.name != "geckodriver" )
			this.Switch("CDwindow-" this.Detail()[1].id ) ; First id always Current Handle

I think it has something to do with this change.


Bert

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 30 Mar 2023, 19:14
by Xeo786
Milchmann wrote:
30 Mar 2023, 00:19
Hello Xeo786,


I pulled down your latest version. Since then I have an error that the current tab is no longer recognised by Chrome. Only the window that is active at the start is recognised. If I change the tab, the first recognised window remains active.

Code: Select all

; new
if( this.name != "geckodriver" )
			this.Switch(this.Detail()[1].id ) ; First id always Current Handle
and old

Code: Select all

if( this.name != "geckodriver" )
			this.Switch("CDwindow-" this.Detail()[1].id ) ; First id always Current Handle

I think it has something to do with this change.


Bert
following is for chrome 110+

Code: Select all

if( this.name != "geckodriver" )
			this.Switch(this.Detail()[1].id ) ; First id always Current Handle
and old is for chrome 110 below...

Code: Select all

if( this.name != "geckodriver" )
			this.Switch("CDwindow-" this.Detail()[1].id ) ; First id always Current Handle
Oh if user is Windows 7 user than chrome wont update I suspect thats the issue, i will soon make few changes.

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 31 Mar 2023, 00:04
by Milchmann
Thanks for the answer, but unfortunately it doesn't make me happy.

Would it perhaps be possible to document such changes in such a way that I only install the updated Rufaydium web driver when Chrome is greater than 110? Currently we still have version 110 here, and that's what I programmed the error into.

One possibility would be to check which version of the browser is currently being used and then it calls the correct code.

To be clear, I appreciate your work and am very happy that something like this has been created by you. :bravo: :bravo:


First of all, I go back to an earlier version of Rufaydium-Webdriver.

Bert

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 31 Mar 2023, 03:21
by Xeo786
Milchmann wrote:
31 Mar 2023, 00:04
Thanks for the answer, but unfortunately it doesn't make me happy.

Would it perhaps be possible to document such changes in such a way that I only install the updated Rufaydium web driver when Chrome is greater than 110? Currently we still have version 110 here, and that's what I programmed the error into.

One possibility would be to check which version of the browser is currently being used and then it calls the correct code.

To be clear, I appreciate your work and am very happy that something like this has been created by you. :bravo: :bravo:


First of all, I go back to an earlier version of Rufaydium-Webdriver.

Bert
It wasn't chrome version it was driver version issue Driver version 110 ran my chrome 111 and I tested with both driver 111 and driver 110 issue has been fixed

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 31 Mar 2023, 03:38
by Milchmann
:bravo: I test it.

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Posted: 01 Apr 2023, 00:24
by magusneo
Xeo786 wrote:
28 Mar 2023, 23:44
magusneo wrote:
28 Mar 2023, 11:17
Can Rufaydium pass the Cloudflare bot checking?
check this site:https://nowsecure.nl//
chrome can't visit it if starting with chromedriver.exe.
yes :shh: here

How can Rufaydium visit https://chat.openai.com/?It always tell me to verify even with the following code

Code: Select all

chrome.Capabilities.addArg("--disable-blink-features=AutomationControlled")