Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post your working scripts, libraries and tools for AHK v1.1 and older
MoUse_G
Posts: 10
Joined: 07 Oct 2021, 00:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by MoUse_G » 31 Jan 2023, 03:43

Ok, let me try.

Thanks for your information 🙏

MoUse_G
Posts: 10
Joined: 07 Oct 2021, 00:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by MoUse_G » 31 Jan 2023, 04:16

@Xeo786
I try change my script with:
Chrome := new Rufaydium()
Session := Chrome.NewSession()
url := "https://nowsecure.nl"
Session.Navigate(url)
Session.Maximize()
sleep, 200
return

And the browser keep refresh and it fail with the undetected chromedriver.

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 » 31 Jan 2023, 04:21

MoUse_G wrote:
31 Jan 2023, 01:42
Hi, @Xeo786, I didn't use a Settimeout.
Usually, to test undetected chromedriver from python, go to the link: https://nowsecure.nl
And here is the link for the undetected chromedriver python library: https://pypi.org/project/undetected-chromedriver/2.1.1/

This is my simple script to test undetected chromedriver with rufaydium:

Code: Select all

ChromeDriver := A_ScriptDir "\chromedriver.exe"
Driver := new RunDriver(ChromeDriver)
Chrome := new Rufaydium()

Session := Chrome.NewSession()

url := "https://nowsecure.nl"

Session.Navigate(url)
Session.Maximize()
sleep, 200
return

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
You cannot use RunDriver Class directly? it would work for early version but not work latest,

Code: Select all

Driver := new RunDriver(ChromeDriver)
Now Rufaydium by self configure and Run driver.

1) make sure driver is not running kill driver (i.e. chromedriver) using taskmager. and try following code

Code: Select all

Chrome := new Rufaydium()
Session := Chrome.NewSession()
url := "https://nowsecure.nl"
Session.Navigate(url)
Session.Maximize()
sleep, 200
return
new Rufaydium() will Download chromedriver (to a_script_dir) if not available, then Run available driver with port 9515, in order to run driver with different port/location or different driver please follow documentation,

for webdriver detection, you should look my this post
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

MoUse_G
Posts: 10
Joined: 07 Oct 2021, 00:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by MoUse_G » 31 Jan 2023, 04:49

I've tried but still can't get to the site: https://nowsecure.nl/

separateattention
Posts: 16
Joined: 19 Oct 2022, 15:30

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by separateattention » 31 Jan 2023, 14:37

@Xeo786 any idea on how to interact with this kind of alert/prompt;

I've used "UserPrompt" and "Session.Alert" without luck.
Attachments
snip.png
snip.png (9.07 KiB) Viewed 4216 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 » 31 Jan 2023, 23:24

MoUse_G wrote:
31 Jan 2023, 04:49
I've tried but still can't get to the site: https://nowsecure.nl/
Implement all these for webdriver detection, its possible to do it using Rufaydium.
"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 » 31 Jan 2023, 23:50

separateattention wrote:
31 Jan 2023, 14:37
@Xeo786 any idea on how to interact with this kind of alert/prompt;

I've used "UserPrompt" and "Session.Alert" without luck.
By Setting UserPrompt you will define what should webdriver, its "ignore" by default so a user can handle it, so you need to change it "ignore",

Now use have to deal it by using manually or Session.Alert()

in your case you have send text to alert and then accept it

Code: Select all

Chrome := Rufaydium()
MsgBox, % "UserPrompt  : " Chrome.capabilities.UserPrompt 
Chrome.capabilities.UserPrompt := "ignore" ; driver will wait for user to deal with alert

Page := Chrome .NewSession
; now do something here for to alert appear 
Page.alert("Send","abc`t123") ; here send some text but using "`t" to emulate tab to get to the next edit box
Page.Alert("accept")
I have tested send tab to alert but this should work Page.alert("Send","`t")

note: you have to make difference between Window alerts and Broswer alerts, both is created by Javascript, but window alert has window gui and broswer alerts are chrome UI based, Windows alert can be handle using AHK easily by winwait or winexist and contorl send and get
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

songdg
Posts: 494
Joined: 04 Oct 2017, 20:04

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by songdg » 01 Feb 2023, 04:32

Xeo786 wrote:
28 Jan 2023, 04:25
songdg wrote:
28 Jan 2023, 02:26
Xeo786 wrote:
20 Jan 2023, 12:03
songdg wrote:
20 Jan 2023, 11:26
Thanks, it's quite easy to use. But when I use my local search engine (www.baidu.com), it dosen't work.
You need to find that element from that particular website, to access it, You need to learn the basics of HTML and Javascript, Use the Devtools of the browser in question to read HTML tag elements class and id.
Thanks, any suggestion of books I should read for a crash course.
no need to read complicated books, start with devtools console and elements and DOM itro, learn how to debug webpage using devtools how to use Java script to access element and data within elements then DOM methods, DOM Document & elements, but you need to there try examples in devtools console,
Thank for the advice :rainbow:

cristalgrip
Posts: 36
Joined: 19 Feb 2023, 15:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 19 Feb 2023, 15:56

I can't figure out a way to get an element based on the text it has written. Any help?
I tried to get a button based on his text ("Enter") with the aim to click on it but without success.

Element := Page.getElementsbyXpath("//*[text()='Enter']")

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 » 20 Feb 2023, 00:44

cristalgrip wrote:
19 Feb 2023, 15:56
I can't figure out a way to get an element based on the text it has written. Any help?
I tried to get a button based on his text ("Enter") with the aim to click on it but without success.

Element := Page.getElementsbyXpath("//*[text()='Enter']")
Hope this would help, as even me was confused with innerText being considered as an innerHTML, sometime innerText are empty but innerHtml are the innerText, :problem:

Code: Select all

#include Rufaydium.ahk

chrome := new Rufaydium() ; to download and launch chrome driver
Page := Chrome.NewSession() ; to create session
Page.Url := "https://www.autohotkey.com/boards/index.php" ; to navigate

Elements := Page.getElementsbyXpath("//*[contains(text(),'Search')]") ; return with elements object that contain 'Search' text

for k, Element in Elements ; here looping through elements
    msgbox, % "TagName: " Element.TagName "`nValue: " Element.Value "`ninnerText: "  Element.innerText "`n`ninnerHTML : " Element.innerHTML "`n`nouterHTML : " Element.outerHTML
    
msgbox, press f12 to quit session and exit driver
return

f12::
Page.quit() ; to quit session
Chome.Exit() ; to exit driver
msgbox, script gonna exit...!
exitapp
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

cristalgrip
Posts: 36
Joined: 19 Feb 2023, 15:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 21 Feb 2023, 15:14

Thank you very much!

I have another question...

I don't understand why this doesn't work and give an empty message box

Code: Select all

this_is_a_function()
{
	Page.Frame(2)
	stringa:="//div[@id=""game-board""]/div[3]/div[1]"
	classe_el:=Page.getElementsbyXpath(stringa)[0].Class
	MsgBox, %classe_el%
}
while this works, giving the class of the object.

Code: Select all

2::
	Page.Frame(2)
	stringa:="//div[@id=""game-board""]/div[3]/div[1]"
	classe_el:=Page.getElementsbyXpath(stringa)[0].Class
	MsgBox, %classe_el%
return 

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 » 22 Feb 2023, 00:14

cristalgrip wrote:
21 Feb 2023, 15:14
I don't understand why this doesn't work and give an empty message box

Code: Select all

this_is_a_function()
{
	Page.Frame(2)
	stringa:="//div[@id=""game-board""]/div[3]/div[1]"
	classe_el:=Page.getElementsbyXpath(stringa)[0].Class
	MsgBox, %classe_el%
}
You should learn about functions, read about Global, Local and Static variables and learn how to pass variable to a function.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

cristalgrip
Posts: 36
Joined: 19 Feb 2023, 15:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 22 Feb 2023, 11:56

Xeo786 wrote:
22 Feb 2023, 00:14
cristalgrip wrote:
21 Feb 2023, 15:14
I don't understand why this doesn't work and give an empty message box

Code: Select all

this_is_a_function()
{
	Page.Frame(2)
	stringa:="//div[@id=""game-board""]/div[3]/div[1]"
	classe_el:=Page.getElementsbyXpath(stringa)[0].Class
	MsgBox, %classe_el%
}
You should learn about functions, read about Global, Local and Static variables and learn how to pass variable to a function.
I'm sorry, maybe I explained myself poorly or I didn't understand the answer. The function has no variables to return and no variables to be passed.
The function should just show a message box with the class of the element.

cristalgrip
Posts: 36
Joined: 19 Feb 2023, 15:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 22 Feb 2023, 11:59

Xeo786 wrote:
22 Feb 2023, 00:14
cristalgrip wrote:
21 Feb 2023, 15:14
I don't understand why this doesn't work and give an empty message box

Code: Select all

this_is_a_function()
{
	Page.Frame(2)
	stringa:="//div[@id=""game-board""]/div[3]/div[1]"
	classe_el:=Page.getElementsbyXpath(stringa)[0].Class
	MsgBox, %classe_el%
}
You should learn about functions, read about Global, Local and Static variables and learn how to pass variable to a function.
Ops, i think i get it. Ignore my previous message

yousef_badr23
Posts: 19
Joined: 26 Aug 2022, 07:18

Chrome Headless

Post by yousef_badr23 » 25 Feb 2023, 06:31

Headless mode no longer working after Chrome update to version 110.0.5481.178. Is this behavior expected or just my pc? I searched the internet and the only relevant topic is that selenium changed its headless mode argument.

PS: Are you planning to support AHK v2?

Thanks!

Update: Used the same method as selenium and now it works even better than before (i.e: can now save cookies in headless mode, didn't work before)
browser.capabilities.addArg("--headless=new")

JerryMaguire
Posts: 16
Joined: 05 Mar 2023, 11:17

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by JerryMaguire » 05 Mar 2023, 11:47

This is my first attempt at programming with AutoHotKey
English is not my main language
Because I use Google translation, please forgive me for the inappropriate expression

cristalgrip
Posts: 36
Joined: 19 Feb 2023, 15:52

Re: Rufaydium WebDriver 1.7.2 (no selenium/websocket)

Post by cristalgrip » 09 Mar 2023, 09:07

There is a way for the webdriver to interact with a canvas element where JavaScript is used to draw, write, insert images ecc dynamically?

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 » 13 Mar 2023, 03:39

cristalgrip wrote:
09 Mar 2023, 09:07
There is a way for the webdriver to interact with a canvas element where JavaScript is used to draw, write, insert images ecc dynamically?
you can use JAVA script, look for Session.ExecuteSync()
"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: Chrome Headless

Post by Xeo786 » 13 Mar 2023, 03:48

yousef_badr23 wrote:
25 Feb 2023, 06:31
PS: Are you planning to support AHK v2?
Yes Rufaydium V2 Alpha Branch
yousef_badr23 wrote:
25 Feb 2023, 06:31
Update: Used the same method as selenium and now it works even better than before (i.e: can now save cookies in headless mode, didn't work before)
browser.capabilities.addArg("--headless=new")
Thank you update...! just added this to capabilities, yah window handling has also been changed which I recently updated.
"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: Chrome Headless

Post by yousef_badr23 » 13 Mar 2023, 14:51

Xeo786 wrote:
13 Mar 2023, 03:48
yousef_badr23 wrote:
25 Feb 2023, 06:31
PS: Are you planning to support AHK v2?
Yes Rufaydium V2 Alpha Branch
[Mod edit: Fixed quote tags, how they were meant to be, I guess.]

Thanks for your great effort!!
I tried my hand at V2 and would like to detail some hiccups (and how I fixed them) while trying the demo you posted at the readme.
There were 2 hiccups, both related to directories
First:
When specifying the location of the chrome webdriver, it would fail to load, but would load correctly when it is in the same folder as my test script.
After digging through the callout stack, I changed line 52 at WDM.ahk to

Code: Select all

this.Target :=  this.Dir "\" this.exe " '" this.param "'"
and then it worked.
Second:
When I would get an error (Error: (126) The specified module could not be found) from the json library when starting my test script. I had to change the native load module to

Code: Select all

Native.LoadModule(A_LineFile '\..\JSON\' (A_PtrSize * 8) 'bit\ahk-json.dll', ['JSON'])
to get it to work.

Once I made these changes, I could finally try the beginning of your demo
Chrome := Rufaydium("Down\webdrivers\chromedriver.exe")
Page := Chrome.NewSession()
Page.url := "https://www.autohotkey.com/boards"
I haven't tried much else :D

Post Reply

Return to “Scripts and Functions (v1)”