Use CDP without CDP script will wait till the page finishes loading, but with CDP need to make your script wait and while can do other stuff but Idk if it's ok to create Create new tab or window while one page is loading or I haven't tried that.HardyMcFly wrote: ↑11 Jun 2022, 04:00Hi
thanks for your work. It is what i needed.
How can I force the next command, before the other command is done?
For example send the next command before site finished loading.
Thanks
Rufaydium WebDriver 1.7.2 (no selenium/websocket)
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
Last edited by Xeo786 on 13 Jun 2022, 02:33, edited 2 times in total.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
You can use incognito modewinkieduck wrote: ↑11 Jun 2022, 01:12I am preferring not to use an existing chrome profile and when I log into a website, there will always be this save password notification. I did read the documentation and tried the Session.Alert commands but they don't seem to have any affect on this window. Is there a built in way to close this? I know there are background settings in chrome to disable this password save offering but each time I run my script, it will always open a new chrome window without any profile setting syncs so this is always an issue. any help would be appreciated.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
Perhaps it is just my computer, but perhaps I'm doing something wrong.
I have the test script + test html file below. I set a variable, year:=2022, when I try to use it for an input using .value or .sendkey it doesn't work, but if I add "" infront of it, it does. I see this with chrome and firefox and not only with byName. Just setting "hello" does work.
Input.htm
I have the test script + test html file below. I set a variable, year:=2022, when I try to use it for an input using .value or .sendkey it doesn't work, but if I add "" infront of it, it does. I see this with chrome and firefox and not only with byName. Just setting "hello" does work.
Code: Select all
#SingleInstance, force
#Include Rufaydium.ahk
Browser:=new Rufaydium()
url:="file:///" StrReplace(A_ScriptDir,"\","/") "/input.htm" ; copied below
Page:=Browser.NewSession()
Page.Navigate(url)
Session:=Browser.getSessionByUrl(url)
Year:=2022
Session.getElementsbyName("input")[0].value:=Year ; empty
Session.getElementsbyName("input")[1].value:="" Year ; works
Session.getElementsbyName("input")[2].SendKey(Year) ; empty
Session.getElementsbyName("input")[3].SendKey("" Year) ; works
Session.getElementsbyName("input")[4].value:="hello" ; works
MsgBox, Now closing script, browser and webdriver
Browser.QuitAllSessions()
Browser.Driver.exit()
Session:=""
Page:=""
ExitApp
Code: Select all
<html>
<head>
<title>test</title>
</head>
<body>
<form>
<input name='i1' type='text' maxlength='5' size='5' tabindex='1' /><br />
<input name='i2' type='text' maxlength='5' size='5' tabindex='1' /><br />
<input name='i3' type='text' maxlength='5' size='5' tabindex='1' /><br />
<input name='i4' type='text' maxlength='5' size='5' tabindex='1' /><br />
<input name='i5' type='text' maxlength='5' size='5' tabindex='1' /><br />
</form>
</body>
</html>
Re: Rufaydium WebDriver 1.6.0 (no selenium/websocket)
If I add in a slight delay in the script, even sleep 100 prior to the click, then the download is saved to the proper folder. Weird!
Re: Rufaydium WebDriver 1.6.0 (no selenium/websocket)
Rufaydium does not have an event handler* for the time being, which may enable AutoHotkey to know if the CDP command has been fully implemented or not?
Webdriver Basics waits for every command to get finished properly but for CDP, it's up to us/code to make the script wait for certain tasks to get finished properly, I am working on the event handler,
TLDR: CDP command takes time to affect (especially commands like changing download folder) and our script does not wait and goes ahead,
Last edited by Xeo786 on 14 Jun 2022, 07:18, edited 1 time in total.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
Any value you are sending/setting is being sent to the driver as a string in a JSON object, String should be covered by double quotes (") as Rufaydium Generates AHK object and cJSON.ahk converts it to JSON (text Payload for HTTP request) for Webdriver.ahk7 wrote: ↑13 Jun 2022, 16:20Perhaps it is just my computer, but perhaps I'm doing something wrong.
I have the test script + test html file below. I set a variable, year:=2022, when I try to use it for an input using .value or .sendkey it doesn't work, but if I add "" infront of it, it does. I see this with chrome and firefox and not only with byName. Just setting "hello" does work.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
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?
All data sent to form elements are required to be strings.
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?
Edit: or much shorterhttps://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)
All data sent to form elements are required to be strings.
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
Yes, it can be fixed using by adding one line, I will try to fix this issue in the next update,ahk7 wrote: ↑14 Jun 2022, 12:28OK 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?
Edit: or much shorterhttps://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)
All data sent to form elements are required to be strings.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
-
- Posts: 78
- Joined: 06 May 2017, 11:07
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
Hi! I just downloaded Rufaydium and put it in a subfolder in my main (root) AHK scripts folder. It downloaded the operadriver.exe file into the root folder and when trying to run a minimal example, it complained that it couldn't find the driver. I copied the driver into the subfoler where Rufaydium.ahk resides, but I'm still getting the same error.
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
Rufaydium downloads the driver itself, read about New Rufaydium()elbitjusticiero wrote: ↑15 Jun 2022, 06:42Hi! I just downloaded Rufaydium and put it in a subfolder in my main (root) AHK scripts folder. It downloaded the operadriver.exe file into the root folder and when trying to run a minimal example, it complained that it couldn't find the driver. I copied the driver into the subfoler where Rufaydium.ahk resides, but I'm still getting the same error.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
I have a request.
I often query the values .outerHTML , .value and .innerText and then click on these elements.
I can only do this with different queries ( base, cdp and evaluate )
I can only do this with different queries. Is it possible to optimise this so that I can only query and then click on everything with cdp as an example?
I know I can do this with Evaluate too, but would have to adapt a lot of lines of code with it.
Thanks
I often query the values .outerHTML , .value and .innerText and then click on these elements.
I can only do this with different queries ( base, cdp and evaluate )
Code: Select all
Chrome := new Rufaydium("chromedriver.exe")
Page := Chrome.getSessionByUrl("https://www.autohotkey.com/boards/")
if !isobject(page)
{
Page := Chrome.NewSession()
Page.Navigate("https://www.autohotkey.com/boards/")
}
msgbox % "`nkeywords innerText from Basic (Autohotkey_H) : " Page.QuerySelectorAll("#page-body > div:nth-child(3) > div > ul.topiclist.forums > li:nth-child(7) > dl > dt > div > a")[0].InnerText "`n"
. "`nkeywords outerHTML from CDP : `n" Page.cdp.QuerySelector("#keywords").outerHTML "`n`n"
. "`nkeywords outerHTML from Evaluate : `n" Page.CDP.Evaluate("document.querySelector('#keywords').outerHTML;").value
I know I can do this with Evaluate too, but would have to adapt a lot of lines of code with it.
Thanks
-
- Posts: 78
- Joined: 06 May 2017, 11:07
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
I know it does, that's why I'm telling you it put the .exe in the root folder, so I had to copy it to the Rufaydium folder, but even so, Rufaydium doesn't find it. ¯\_(ツ)_/¯Xeo786 wrote: ↑15 Jun 2022, 07:45Rufaydium downloads the driver itself, read about New Rufaydium()elbitjusticiero wrote: ↑15 Jun 2022, 06:42Hi! I just downloaded Rufaydium and put it in a subfolder in my main (root) AHK scripts folder. It downloaded the operadriver.exe file into the root folder and when trying to run a minimal example, it complained that it couldn't find the driver. I copied the driver into the subfoler where Rufaydium.ahk resides, but I'm still getting the same error.
-
- Posts: 78
- Joined: 06 May 2017, 11:07
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
This is the error I'm getting:
(I said in a reply that didn't get published that I know Rufaydium downloads the driver, but even so, it doesn't seem to find it. It gets downloaded to the main script folder, and even after I manually copy it to the Rufaydium folder, Rufaydium doesn't see it.)
(I said in a reply that didn't get published that I know Rufaydium downloads the driver, but even so, it doesn't seem to find it. It gets downloaded to the main script folder, and even after I manually copy it to the Rufaydium folder, Rufaydium doesn't see it.)
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
@elbitjusticiero perhaps try it like so
Code: Select all
Browser:=new Rufaydium("operadriver.exe")
Page:=Browser.NewSession("c:\path-to\opera.exe")
-
- Posts: 78
- Joined: 06 May 2017, 11:07
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
Do you mean that what Rufaydium is not fiding is not the driver, but the browser itself?
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
Yes, it can't find the browser (opera.exe) so if you explicitly call it via Page:=Browser.NewSession("c:\path-to\opera.exe") it hopefully works, did you try it already?
-
- Posts: 78
- Joined: 06 May 2017, 11:07
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
Yes, but:
This is the error I'm getting now.
My Opera is up to date so the software is complaining that it only supports a browser that doesn't exist yet.
This is the error I'm getting now.
My Opera is up to date so the software is complaining that it only supports a browser that doesn't exist yet.
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
You can manually download drivers here https://github.com/operasoftware/operachromiumdriver/releases just match the versions overwrite the one in your folder and start the script again, should work
-
- Posts: 78
- Joined: 06 May 2017, 11:07
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
I'll see if that solves the problem, thank you!
Re: Rufaydium WebDriver 1.6.1 (no selenium/websocket)
Basic WDElement objects store WebDriver element id, and CDP element object stores DOM "nodeid", these are API-level communications that let us do specific tasks,
I compare DOM remote Object ids with WDElement ids and try to match other stuff in order to have a switching ability between CDP to basic at any point/for any element pointer, I haven't found any similarity, unfortunately,
Evaluating javascript is something else that also gives us vast control over the page,
There is evaluate(JS) for CDP, which passes JS,
There are method ExecuteSync(Script,Args*) and ExecuteAsync(Script,Args*), for Basic which executes JS as well.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory