Page 16 of 31
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 05 Aug 2022, 08:45
by Xeo786
Milchmann wrote: ↑05 Aug 2022, 08:27
Xeo786 wrote: ↑05 Aug 2022, 07:28
Milchmann wrote: ↑05 Aug 2022, 06:45
But what still doesn't work is
DoubleClick and contextmenu.
Code: Select all
E := driver.QuerySelector("#T0444333 > tbody > tr:nth-child(5)").doubleClick()
if % e.Error
MsgBox % e.Error
I would like you to try
Code: Select all
driver.QuerySelector("#T0444333 > tbody > tr:nth-child(5)").Execute("var evObj = new MouseEvent('dblclick', {bubbles: true, cancelable: true, view: window});arguments[0].dispatchEvent(evObj);")
Does not work and no errors
just tested it working double click and context menu
Code: Select all
Page := GetRufaydium("https://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_event_dblclick")
page.frame(0)
e := Page.querySelector("p")
etext := e.innerText
e.Execute("arguments[0].dispatchEvent(new MouseEvent('dblclick', {bubbles: true, cancelable: true, view: window}));")
msgbox, % "just look at above chrome alert poped up due to double click on line saying:`n" chr(34) etext chr(34)
page.click(2) ; this will close alert, need to place it twice
page.click(2) ; here your right context menu
return
GetRufaydium(URL)
{
; get chrome driver / runs chrome driver if not running, download driver if available in A_ScriptDir
; Run Chrome Driver with default parameters and loads deafult capabilities
Chrome := new Rufaydium()
Page := Chrome.getSessionByUrl(URL) ; check page (created by driver) if already exist
if !isobject(page) ; checcking if Session with url exist
{
Page := Chrome.getSession(1,1) ; try getting first session first tab
if isobject(page) ; if exist
Page.NewTab() ; create new tab instead new session
else ; if does not exist
Page := Chrome.NewSession() ; create new session ; Page.Exit() if any session manually closed by user which causes lag
Page.Navigate(URL) ; navigate
}
return page
}
You need to look into actions class and how it works, to move pointer to some element and clicking on them, as element.move() has been depreciated and no longer working soon I gonna remove it or maybe changed using actions class to move the pointer to that element.
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 05 Aug 2022, 10:25
by Milchmann
Thank you, your example works.
Code: Select all
d := driver.QuerySelector("#T0444333 > tbody > tr:nth-child(13)")
MsgBox % etext := d.innerText
e := d.Execute("arguments[0].dispatchEvent(new contextmenu('dbl', {bubbles: true, cancelable: true, view: window}));")
if % e.Error
MsgBox e.Error
But not mine. I get: "Javascript error"
And I need the context menu for the element ( d ) .
As an example this link:
https://codepen.io/SitePoint/pen/pywPEQ
The example you gave referred to the page. That also works.
I hope you can help
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 06 Aug 2022, 01:40
by hotcheesesoup
I am using a timer to constantly poll Chrome to always make sure I'm interacting with the active tab. This works great almost all of the time, but it has issues when it comes to alerts generated by the page. The alerts will be automatically closed as if they were cancelled, versus as if they were accepted. I've created a hotkey that will temporarily stop my timer so the alert can be confirmed, but this is less than ideal.
Code: Select all
Session.Alert("GET") ; getting text from pop up msg
Session.Alert("accept") ; pressing OK / accept pop up msg
Session.Alert("dismiss") ; pressing cancel / dismiss pop up msg
Session.Alert("Send","some text") ; sending a Alert / pop up msg
I know these methods exist, but the prompt lasts only a fraction of a second. Is it possible for Rufaydium/AHK to see an alert has popped so that I can tell AHK to pause the script?
Would using Session.Alert("accept") on each pass of the timer work, even if there isn't an active alert at the time?
Thanks!
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 08 Aug 2022, 00:21
by MoUse_G
Xeo786 wrote: ↑05 Aug 2022, 00:56
MoUse_G wrote: ↑04 Aug 2022, 08:27
I can't login to gmail, when using Rufaydium with chromedriver and geckodriver. Has anyone had the same experience with this?
You can load a chrome profile that may have already logged in Gmail,
.setUserProfile("Profile 1")
Thank you
@Xeo786
I have fixed the error, because there is a chrome browser currently open.
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 08 Aug 2022, 00:44
by hotcheesesoup
hotcheesesoup wrote: ↑06 Aug 2022, 01:40
I am using a timer to constantly poll Chrome to always make sure I'm interacting with the active tab. This works great almost all of the time, but it has issues when it comes to alerts generated by the page. The alerts will be automatically closed as if they were cancelled, versus as if they were accepted. I've created a hotkey that will temporarily stop my timer so the alert can be confirmed, but this is less than ideal.
Code: Select all
Session.Alert("GET") ; getting text from pop up msg
Session.Alert("accept") ; pressing OK / accept pop up msg
Session.Alert("dismiss") ; pressing cancel / dismiss pop up msg
Session.Alert("Send","some text") ; sending a Alert / pop up msg
I know these methods exist, but the prompt lasts only a fraction of a second. Is it possible for Rufaydium/AHK to see an alert has popped so that I can tell AHK to pause the script?
Would using Session.Alert("accept") on each pass of the timer work, even if there isn't an active alert at the time?
Thanks!
I dug into this and found out it is part of the Capabilities class. Here is the info:
https://www.w3.org/TR/webdriver2/#dfn-user-prompt-handler. I added this and it fixed the issue.
Code: Select all
this.cap.capabilities.alwaysMatch.unhandledPromptBehavior := "ignore"
My guess is if you don't choose an option, it defaults to "dismiss." I tried "accept" first, which seemed fine, but I like having the choice of how to proceed.
Thanks!
-HCS
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 10 Aug 2022, 05:52
by Xeo786
hotcheesesoup wrote: ↑08 Aug 2022, 00:44
I dug into this and found out it is part of the Capabilities class. Here is the info:
https://www.w3.org/TR/webdriver2/#dfn-user-prompt-handler. I added this and it fixed the issue.
Code: Select all
this.cap.capabilities.alwaysMatch.unhandledPromptBehavior := "ignore"
My guess is if you don't choose an option, it defaults to "dismiss." I tried "accept" first, which seemed fine, but I like having the choice of how to proceed.
Thanks!
-HCS
Thank you so much, Great...!
I have just implemented
Userprompt parameter
Code: Select all
#include Rufaydium.ahk
Chrome := new Rufaydium()
msgbox, % Chrome.Capabilities.UserPrompt ; get
Chrome.Capabilities.UserPrompt := "ignore" ; set
it should work, I haven't tested it above code
, I haven't needed to interact with user prompt alerts from webpages.
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 10 Aug 2022, 05:59
by Xeo786
Milchmann wrote: ↑05 Aug 2022, 10:25
But not mine. I get: "Javascript error"
And I need the context menu for the element ( d ) .
As an example this link:
https://codepen.io/SitePoint/pen/pywPEQ
The example you gave referred to the page. That also works.
I hope you can help
Make sure you are accsing correct element,
and this link "
https://codepen.io/SitePoint/pen/pywPEQ" is loading that page in a frame, make sure you are switching that specific frame, and getting that element.
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 12 Aug 2022, 04:43
by Milchmann
Make sure you are accsing correct element,
and this link "
https://codepen.io/SitePoint/pen/pywPEQ" is loading that page in a frame, make sure you are switching that specific frame, and getting that element.
I test it, thanks
I have a new problem. When I compile the ahk file into an exe, I then get an error message :
Line Text: switch this.Name
Error: This Line does not contain a recognised action.
Can you help?
[Mod edit: Fixed quote tag. Starting tag doesn't start with a /, only the finishing one(s).]
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 12 Aug 2022, 06:14
by gregster
Milchmann wrote: ↑12 Aug 2022, 04:43
I have a new problem. When I compile the ahk file into an exe, I then get an error message :
Line Text: switch this.Name
Error: This Line does not contain a recognised action.
Usually this means that your AHK version is too old, since
Switch is a relatively new statement added to AHK (v1.1.31+).
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 16 Aug 2022, 06:15
by Milchmann
gregster wrote: ↑12 Aug 2022, 06:14
Milchmann wrote: ↑12 Aug 2022, 04:43
I have a new problem. When I compile the ahk file into an exe, I then get an error message :
Line Text: switch this.Name
Error: This Line does not contain a recognised action.
Usually this means that your AHK version is too old, since
Switch is a relatively new statement added to AHK (v1.1.31+).
Thank you, I have updated AUtohotkey
Re: Rufaydium WebDriver 1.6.3 (no selenium/websocket)
Posted: 16 Aug 2022, 19:47
by noslined
How can I select an specific item from a list like this?
https://forms.monday.com/forms/cb21c427bf8e1773afa84d6a1938bcea?r=use1
- image.png (30.22 KiB) Viewed 3782 times
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 17 Aug 2022, 05:21
by byzod
Rufaydium is running successfully and downloaded geckodriver for me
But it didn't found firefox.exe, maybe because I didn't install it but download from
firefox ftp
This the code and result:
Code: Select all
#F1::
{
Firefox := new Rufaydium("geckodriver.exe")
Page := Firefox.NewSession()
Page.Navigate("https://www.autohotkey.com/")
Return
}
- 1.png (97.86 KiB) Viewed 3687 times
The geckodriver your script downloaded for me:
Code: Select all
C:\App\Something\AutoHotkey\Script>geckodriver -V
geckodriver 0.31.0 (b617178ef491 2022-04-06 11:57 +0000)
My firefox info: (as I said, download and unzip from
ftp)
Code: Select all
Name Firefox
Version 104.0b9
Version ID 20220811191329
OS Windows_NT 10.0 19044
Binary C:\App\Something\Firefox\firefox.exe
Profile C:\App\Pool\FxQ
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 17 Aug 2022, 05:38
by Xeo786
byzod wrote: ↑17 Aug 2022, 05:21
Rufaydium is running successfully and downloaded geckodriver for me
But it didn't found firefox.exe, maybe because I didn't install it but download from
firefox ftp
This the code and result:
Code: Select all
#F1::
{
Firefox := new Rufaydium("geckodriver.exe")
Page := Firefox.NewSession()
Page.Navigate("https://www.autohotkey.com/")
Return
}
1.png
The geckodriver your script downloaded for me:
Code: Select all
C:\App\Something\AutoHotkey\Script>geckodriver -V
geckodriver 0.31.0 (b617178ef491 2022-04-06 11:57 +0000)
My firefox info: (as I said, download and unzip from
ftp)
Code: Select all
Name Firefox
Version 104.0b9
Version ID 20220811191329
OS Windows_NT 10.0 19044
Binary C:\App\Something\Firefox\firefox.exe
Profile C:\App\Pool\FxQ
Firefox should be installed so Driver can detect firefox.exe path by default, and you need to pass firefox.exe path in case using portable Firefox
Code: Select all
Page := Firefox.NewSession(FirefoxApplicationpath)
Re: Rufaydium WebDriver 1.6.3 (no selenium/websocket)
Posted: 17 Aug 2022, 05:53
by Xeo786
sorry, I am unable to access the URL, it might be blocked for me.
Simple dropdown can be selected using
element.value := aValuefromOptions where options are tagnames of the Child elements
Code: Select all
Chrome := new Rufaydium()
Page := GetRufaydium("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_optgroup")
page.frame(0)
msgbox, now it will select "mercedes"
page.getElementByID("cars").value := "mercedes"
return
; GetRufaydium(URL) gets existing session
; stops us creatting multiple sessions again and again
; make sure do not manually close driver / chrome.driver.exit()
; by Xeo786
GetRufaydium(URL)
{
; get chrome driver / runs chrome driver if not running, download driver if available in A_ScriptDir
; Run Chrome Driver with default parameters and loads deafult capabilities
Chrome := new Rufaydium()
Page := Chrome.getSessionByUrl(URL) ; check page (created by driver) if already exist
if !isobject(page) ; checcking if Session with url exist
{
Page := Chrome.getSession(1,1) ; try getting first session first tab
if isobject(page) ; if exist
Page.NewTab() ; create new tab instead new session
else ; if does not exist
Page := Chrome.NewSession() ; create new session ; Page.Exit() if any session manually closed by user which causes lag
Page.Navigate(URL) ; navigate
}
return page
}
there is also a
example, dealing with complicated dropdown lists, which literally need to be clicked.
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 17 Aug 2022, 07:44
by Milchmann
Hi,
2 times abnormalities:
Code: Select all
MsgBox, % clipboard := RunDriver.help("C:\TEMP\Rufaydium\chromedriver.exe")
hangs on
088: While,!FileExist(this.Dir "\dir.txt")
089: Sleep,200 (0.19)
and
Code: Select all
Chrome.Capabilities.RemoveArg("--disable-background-networking")
Chrome.Capabilities.RemoveArg("--disable-backgrounding-occluded-windows")
Chrome.Capabilities.RemoveArg("--disable-default-apps")
Chrome.Capabilities.RemoveArg("--disable-popup-blocking")
does not remove the parameters.
Thanks
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 17 Aug 2022, 08:32
by Xeo786
Milchmann wrote: ↑17 Aug 2022, 07:44
Hi,
2 times abnormalities:
Code: Select all
MsgBox, % clipboard := RunDriver.help("C:\TEMP\Rufaydium\chromedriver.exe")
hangs on
Code: Select all
088: While,!FileExist(this.Dir "\dir.txt")
089: Sleep,200 (0.19)
Make sure that driver is not running already running/not even being used by Rufaydium.
Milchmann wrote: ↑17 Aug 2022, 07:44
Code: Select all
Chrome.Capabilities.RemoveArg("--disable-background-networking")
Chrome.Capabilities.RemoveArg("--disable-backgrounding-occluded-windows")
Chrome.Capabilities.RemoveArg("--disable-default-apps")
Chrome.Capabilities.RemoveArg("--disable-popup-blocking")
does not remove the parameters.
Thanks
to RemoveArg there should be some[/code] available / added before into the Capabilities.
Rufaudium does not load any CMD arguments by default
Code: Select all
#include Rufaydium.ahk
Chrome := new Rufaydium()
;Chrome.Capabilities.IncognitoMode := 1 ; enable this like it will show you args msgbox and IncognitoMode argument
Arguments := Chrome.Capabilities.cap.capabilities.alwaysMatch[Chrome.driver.Options].args
if Arguments
msgbox, % json.dump(Arguments,1)
else
msgbox, it has not arguments
return
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 19 Aug 2022, 06:22
by byzod
Xeo786 wrote: ↑17 Aug 2022, 05:38
Firefox should be installed so Driver can detect firefox.exe path by default, and you need to pass firefox.exe path in case using portable Firefox
Code: Select all
Page := Firefox.NewSession(FirefoxApplicationpath)
Thanks it works!
Another question, I read the README.md but didn't found out how to interact with current browser yet
What I want:
I'm using firefox
with my own profile, browse some website for example google.com
Then ahk check the target on page that I interacted with, for example
the content in search box that I just typed ("test7" in this case)
Then handle the info ahk just get, for example open a new tab and
search the content with yandex.com (just for example, you can't always get what you want from url ofc)
Is it possible to do with this script?
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 20 Aug 2022, 01:19
by Xeo786
byzod wrote: ↑19 Aug 2022, 06:22
Another question, I read the README.md but didn't found out how to interact with current browser yet
Rufaydium is based on Webdriver, normally running Browser instances is not Webdriver Sessions. you cannot access such browser windows not connected to the Webdriver (running in process).
Please share your Rufaydium code...! I would like to help with your code,
There is so much you can do with Webdriver, I hope Rufaydium README.md will help you,
if you know some functionality that is not supported by Rufaydium but Webdriver is offering just point it out I will try to add it to Rufaydium.
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 20 Aug 2022, 02:04
by byzod
Xeo786 wrote: ↑20 Aug 2022, 01:19
Please share your Rufaydium code...! I would like to help with your code,
There is so much you can do with Webdriver, I hope Rufaydium README.md will help you,
if you know some functionality that is not supported by Rufaydium but Webdriver is offering just point it out I will try to add it to Rufaydium.
This is the code I trying to write
1. Open firefox, open
target link, run ahk script below
2. Press win+F1
3. (Expect result) A message box shows: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Since it's not working, I have only pseudo code to share:
Code: Select all
; test
#F1::
{
firefoxBinPath := "C:\App\Firefox\firefox.exe" ; where firefox is
Fx := new Rufaydium()
Page1 := Fx.GetCurrentSession(firefoxBinPath) ; Get current page of firefox
Title := Page1.QuerySelector(".topic-title") ; Found target DOM element
MsgBox % Title.textContent ; Get info from target element
Page1.exit()
Return
}
Re: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Posted: 20 Aug 2022, 02:35
by Xeo786
byzod wrote: ↑20 Aug 2022, 02:04
Xeo786 wrote: ↑20 Aug 2022, 01:19
Please share your Rufaydium code...! I would like to help with your code,
There is so much you can do with Webdriver, I hope Rufaydium README.md will help you,
if you know some functionality that is not supported by Rufaydium but Webdriver is offering just point it out I will try to add it to Rufaydium.
This is the code I trying to write
1. Open firefox, open
target link, run ahk script below
2. Press win+F1
3. (Expect result) A message box shows: Rufaydium WebDriver 1.7.0 (no selenium/websocket)
Since it's not working, I have only pseudo code to share:
Code: Select all
; test
#F1::
{
firefoxBinPath := "C:\App\Firefox\firefox.exe" ; where firefox is
Fx := new Rufaydium()
Page1 := Fx.GetCurrentSession(firefoxBinPath) ; Get current page of firefox
Title := Page1.QuerySelector(".topic-title") ; Found target DOM element
MsgBox % Title.textContent ; Get info from target element
Page1.exit()
Return
}
this
Fx := new Rufaydium() will download chromedriver, there is geckodriver for firefox please read
this
Following code will download geckodriver,
Code: Select all
Fx := new Rufaydium("geckodriver")
Fx.GetCurrentSession() is not Rufaydium class method (did you add this?), You need to learn how to get existing Session after even reloading AHK script see
this,
Following function is a example to get existing FF session,
Code: Select all
FXPage := GetRufaydiumFX("someurlhere")
return
; GetRufaydiumFX(URL) gets existing session
; stops us creatting multiple sessions again and again
; make sure do not manually close driver / FX.driver.exit()
; by Xeo786
GetRufaydiumFX(URL)
{
; get Firefox geckodriver / runs chrome driver if not running, download driver if available in A_ScriptDir
; Run Firefox geckodriver with default parameters and loads deafult capabilities
FX := new Rufaydium("geckodriver")
Page := FX.getSessionByUrl(URL) ; check page (created by driver) if already exist
if !isobject(page) ; checcking if Session with url exist
{
Page := FX.getSession(1,1) ; try getting first session first tab
if isobject(page) ; if exist
Page.NewTab() ; create new tab instead new session
else ; if does not exist
Page := FX.NewSession() ; create new session ; Page.Exit() if any session manually closed by user which causes lag
Page.Navigate(URL) ; navigate
}
return page
}