Post your working scripts, libraries and tools for AHK v1.1 and older
-
Xeo786
- Posts: 759
- Joined: 09 Nov 2015, 02:43
- Location: Karachi, Pakistan
Post
by Xeo786 » 16 Jun 2022, 02:49
Xeo786 wrote: ↑15 Jun 2022, 02:04
ahk7 wrote: ↑14 Jun 2022, 12:28
OK I didn't realise, but is that common practice that you have to convert numbers to strings using webdriver?
If I use
years:="2022" it does it indeed work as expected (hence the "hello" does too of course).
Shouldn't
Rufaydium convert numbers to strings for the .value .sendkey options? That is what I expected and perhaps others too.
If not, it should probably be added to the documentation?
https://github.com/Xeo786/Rufaydium-Webdriver/blob/main/README.md?plain=1#L579 wrote:
;setting value
Element.value := "somevalue"
; Note: when sending a number or variable representing a number, convert it to a string first:
; Element.value := "2022" and not Element.value := 2022
; or
; year := "2022" ; not year := 2022
; Element.value := year
; same goes for .SendKey("2022") and .SendKey(year)
; Alternative prepend variables with a "" to convert it to a string:
; year := 2022
; .value("" year)
; .SendKey("" year)
Edit: or much shorter
All data sent to form elements are required to be strings.
Yes, it can be fixed using by adding one line, I will try to fix this issue in the next update,
I was looking into this issue and was fascinated following results, AHK considers both vars
x := 5 and y := "6" numbers but cjson somehow knows which is string and which one is number,
Code: Select all
x := {"value":5}, y := {"value":"6"}
msgbox, % "<" x.value "><" y.value ">`n X isnumber:" Isnumber(x.value) "`n y isnumber:" Isnumber(y.value)
msgbox % x := json.dump(x) "`n" y := json.dump(y)
x := json.load(x), y := json.load(y),
msgbox, % "<" x.value "><" y.value ">`n X isnumber:" Isnumber(x.value) "`n y isnumber:" Isnumber(y.value)
msgbox % x := json.dump(x) "`n" y := json.dump(y)
return
Isnumber(var){
if var is number
return 1
}
"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
Post
by Milchmann » 16 Jun 2022, 03:21
Thanks, I wanted to try it at least once. Since I often don't get any values for .value with .cdp, but with .evaluate I will probably switch completely to .evaluate.
Thank you for your commitment.
-
Milchmann
- Posts: 112
- Joined: 05 Nov 2016, 08:50
Post
by Milchmann » 17 Jun 2022, 00:16
Hi,
I think I found little bugs:
Code: Select all
cc := page.status()
msgbox % json.dump(cc) ; no value
Msgbox, % json.dump(page.Detail()) ; no value
and
Code: Select all
msgbox % Page.GetTabs() ; no value!
And as an addition. Can you possibly add the following function in Rufaydium for the respective session called:
Code: Select all
Page := Chrome.getSession(1)
Msgbox % chrome.Status_session()
Status_Session()
{
return this.Request( this.DriverUrl "/sessions","GET")
}
I think some people can work with it too.
Thanks
Last edited by
Milchmann on 19 Jun 2022, 02:39, edited 1 time in total.
-
Xeo786
- Posts: 759
- Joined: 09 Nov 2015, 02:43
- Location: Karachi, Pakistan
Post
by Xeo786 » 18 Jun 2022, 01:21
Milchmann wrote: ↑17 Jun 2022, 00:16
Page := Chrome.getSession(1)
Msgbox % chrome.Status_session()
Status_Session()
{
return this.Request( this.DriverUrl "/sessions","GET")
}
I think some people can work with it too.
Thanks
Just updated Rufaydium,
try
Code: Select all
Msgbox, % json.dump(Chrome.Sessions())
"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
Post
by Milchmann » 18 Jun 2022, 07:25
Code: Select all
Just updated Rufaydium,
try
Code: Select all - Download - Toggle Line numbers
Msgbox, % json.dump(Chrome.Sessions())
works good , Thanks.
The little 2 bugs are still being eliminated?
-
Xeo786
- Posts: 759
- Joined: 09 Nov 2015, 02:43
- Location: Karachi, Pakistan
Post
by Xeo786 » 20 Jun 2022, 05:08
Milchmann wrote: ↑17 Jun 2022, 00:16
Hi,
I think I found little bugs:
Code: Select all
cc := page.status()
msgbox % json.dump(cc) ; no value
Msgbox, % json.dump(page.Detail()) ; no value
Just fixed Following:
Rufaydium.Status()
Session.Detail()
GetTabs() return with UUIDs of Tabs you can json dump result
Code: Select all
msgbox % json.dump(Page.GetTabs())
but user should use
SwitchbyTitle(title) or
SwitchbyUrl(url) 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
Post
by Milchmann » 20 Jun 2022, 08:49
Xeo786 wrote: ↑20 Jun 2022, 05:08
Just fixed Following:
Rufaydium.Status() Chrome.status() ?
Session.Detail() work, thanks
Milchmann wrote: ↑17 Jun 2022, 00:16
Code: Select all
msgbox % Page.GetTabs() ; no value!
msgbox % json.dump(Page.GetTabs())
but user should use
SwitchbyTitle(title) or
SwitchbyUrl(url) instead,
My mistake, sorry. I wanted to find out the number of tabs.
-
Xeo786
- Posts: 759
- Joined: 09 Nov 2015, 02:43
- Location: Karachi, Pakistan
Post
by Xeo786 » 21 Jun 2022, 06:24
Following Example describes how we can access innerHTML and outerHTML of an element from the main/Nested frames and
None Headless mode Printing PDF for Frames.
Code: Select all
#include Rufaydium.ahk
Chrome := new Rufaydium()
Page := Chrome.getSessionByUrl("https://www.easyhtmlcode.com/frames.html")
if !isobject(page)
{
Page := Chrome.NewSession()
Page.Navigate("https://www.easyhtmlcode.com/frames.html")
}
; printing pages with frames
; We can only have access to available HTML using webdriver, we cannot acces HTML from nasted frames
; by switching frame we can access specific frame's HTML
Page.ParentFrame()
page.print(A_ScriptDir "\Main page.pdf") ; as Main page HTML has no visible content therefore printed PDF is empty
x := page.getElementsbyName("frameset")[0] ; accessing element from main frame
msgbox, % h := x.innerHTML
msgbox, % h := x.outerHTML
Page.Frame(0)
x := page.getelementbyid("container") ; accessing element from frame 0
msgbox, % h := x.innerHTML
msgbox, % h := x.outerHTML
page.print(A_ScriptDir "\Frame 0.pdf") ; pdf print from frame 0
Page.ParentFrame()
Page.Frame(1)
x := page.getelementbyid("footer") ; accessing element from frame 1
msgbox, % h := x.innerHTML
msgbox, % h := x.outerHTML
page.print(A_ScriptDir "\Frame 1.pdf") ; pdf print from frame 1
Page.ParentFrame()
return
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
-
Xeo786
- Posts: 759
- Joined: 09 Nov 2015, 02:43
- Location: Karachi, Pakistan
Post
by Xeo786 » 22 Jun 2022, 02:08
@Milchmann I have just fixed the getting value, we were facing
Code: Select all
#include Rufaydium.ahk
Chrome := new Rufaydium()
Page := Chrome.getSessionByUrl("https://www.autohotkey.com/boards/")
if !isobject(page)
{
Page := Chrome.NewSession()
Page.Navigate("https://www.autohotkey.com/boards/")
}
e := Page.QuerySelector("#keywords")
e.value := "xyz"
msgbox, % e.value
"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
Post
by Milchmann » 22 Jun 2022, 03:20
Xeo786 wrote: ↑22 Jun 2022, 02:08
@Milchmann I have just fixed the getting value, we were facing
Top !!! Thanks
-
Xeo786
- Posts: 759
- Joined: 09 Nov 2015, 02:43
- Location: Karachi, Pakistan
Post
by Xeo786 » 22 Jun 2022, 08:16
Rufaydium 1.6.3 can manipulate Elements without CDP, which wasn't possible previously.
Following example describes element modifications.
Code: Select all
#include Rufaydium.ahk
Chrome := new Rufaydium()
Page := Chrome.getSessionByUrl("https://www.autohotkey.com/boards/")
if !isobject(page)
{
Page := Chrome.NewSession()
Page.Navigate("https://www.autohotkey.com/boards/")
}
e := Page.querySelector(".forumtitle")
msgbox % "This innerText going to change on page>>>" e.innerText
e.innerText := "Rufaydium...."
msgbox % "innerText :" e.innerText
e := Page.QuerySelector("#keywords")
e.Name := "abcd"
e.id := "Mywords"
e.Title := "My Title"
e.Class := "My Class"
e.value := "My Value"
msgbox % "Name: " e.Name "`nID: " e.id "`nTitle: " e.Title "`nClass: " e.Class "`nValue: " e.value
html = <button name="Rufaydium" id="MyButton" >Rufaydium</button>
e.outerHTML := html
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
-
HardyMcFly
- Posts: 2
- Joined: 02 Feb 2022, 19:08
Post
by HardyMcFly » 23 Jun 2022, 04:34
How can i interact with the chrome "Save As" window? I've tried, but did'nt come to a solution, because i can't access the "save as" window with rufaydium commands. Just for example send{Enter} commands, but that is not, what i want.
-
Xeo786
- Posts: 759
- Joined: 09 Nov 2015, 02:43
- Location: Karachi, Pakistan
Post
by Xeo786 » 23 Jun 2022, 05:07
HardyMcFly wrote: ↑23 Jun 2022, 04:34
How can i interact with the chrome "Save As" window? I've tried, but did'nt come to a solution, because i can't access the "save as" window with rufaydium commands. Just for example send{Enter} commands, but that is not, what i want.
I am curious how you are getting "Save As" window using Rufaydium.
btw you can extract HTML,
Code: Select all
Chrome := new Rufaydium()
Page := Chrome.NewSession()
Page.Navigate("https://www.autohotkey.com/boards/")
FileAppend, % Page.HTML, % a_desktop "\my page.html" ; there you appened page HTML
You need to switch to specific frames for its html, In case Page has nested frames. Nest them into one html is also a hazel,
"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
Post
by Milchmann » 23 Jun 2022, 10:22
Hi,
with your last version 1 error.
Code: Select all
MsgBox % Page.QuerySelectorAll("123456").Count() ;
The element does not exist, yet I get 1 with Count().
and
Page.Refresh()
MsgBox, Page refresh complete
Does not work.
-
usafer
- Posts: 6
- Joined: 30 Nov 2021, 09:09
Post
by usafer » 23 Jun 2022, 11:55
Hey.
I have an issue trying the first time.
It looks like a message:
'unable to download driver
Rufaydium exiting'.
I tryed to download driver (chromedriver.exe) manually and put it to same folder but doesn't helps.
Also I tryed auto-download script from this topic and got the same.
What I do wrong?
-
Xeo786
- Posts: 759
- Joined: 09 Nov 2015, 02:43
- Location: Karachi, Pakistan
Post
by Xeo786 » 23 Jun 2022, 14:34
Milchmann wrote: ↑23 Jun 2022, 10:22
Hi,
with your last version 1 error.
Code: Select all
MsgBox % Page.QuerySelectorAll("123456").Count() ;
The element does not exist, yet I get 1 with Count().
and
Page.Refresh()
MsgBox, Page refresh complete
Does not work.
My bad I tried implementing error handling to .findelement()
If you Json dump the return object from queryselectorall() you will find error object saying "no such element" that is why count() says 1, I should undo the error handling,
And I haven't done anything to refresh,
I will look into this by Monday.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
-
Xeo786
- Posts: 759
- Joined: 09 Nov 2015, 02:43
- Location: Karachi, Pakistan
Post
by Xeo786 » 23 Jun 2022, 14:38
usafer wrote: ↑23 Jun 2022, 11:55
Hey.
I have an issue trying the first time.
It looks like a message:
'unable to download driver
Rufaydium exiting'.
I tryed to download driver (chromedriver.exe) manually and put it to same folder but doesn't helps.
Also I tryed auto-download script from this topic and got the same.
What I do wrong?
Can you share code you are trying to run I can't say anything, you can do following checks
1) kill driver if it's already running using task manager
2) update chrome
3) try run driver manually if it's manage create http server successfully than close it and try Rufaydium
"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
Post
by Milchmann » 30 Jun 2022, 06:52
Xeo786 wrote: ↑23 Jun 2022, 14:34
Milchmann wrote: ↑23 Jun 2022, 10:22
Hi,
with your last version 1 error.
Code: Select all
MsgBox % Page.QuerySelectorAll("123456").Count() ;
The element does not exist, yet I get 1 with Count().
and
Page.Refresh()
MsgBox, Page refresh complete
Does not work.
My bad I tried implementing error handling to .findelement()
If you Json dump the return object from queryselectorall() you will find error object saying "no such element" that is why count() says 1, I should undo the error handling,
And I haven't done anything to refresh,
I will look into this by Monday.
Count works, Thank You
But
Code: Select all
Page.Refresh()
Page.Forward()
Page.back()
does not work. As I only need this now, I have not noticed it until now
-
usafer
- Posts: 6
- Joined: 30 Nov 2021, 09:09
Post
by usafer » 01 Jul 2022, 02:05
My apologies for the delay, Xeo786.
Yes, I've closed all, if Rufaydium doesn't work (every time in my case).
This is the code I've got on this topic and what I trying to use:
Code: Select all
#SingleInstance, force
;#Include %A_ScriptDir%\lib
#Include Rufaydium.ahk
ChromeDriver := A_ScriptDir "\chromedriver.exe"
url:="https://www.autohotkey.com/boards/"
; choose different driver in order to automate different Browser
Driver := new RunDriver(ChromeDriver) ; running driver
Chrome := new Rufaydium(Driver) ; this will return control over Browser
; choosing Browser Capabilities, by using Capabilities you can make custom profile for specific need
Chrome.capabilities := Capabilities.ChromeDefault
; this is how we create session
Page := Chrome.NewSession()
Page.Navigate(url)
GS := Chrome.getSessionByUrl(url)
Element := GS.getElementsbyXpath("//*[@id=""keywords""]")
; or
; element:=GS.getElementbyID("keywords")
element[1].value:="Rufaydium"
element[1].SendKey(key.enter)
MsgBox, Now closing script, chrome and webdriver
GS:=""
Page := ""
;Chrome.QuitAllSessions()
driver.exit()
ExitApp