ositoMalvado wrote: ↑30 Jun 2022, 15:47
Thanks for the answer, but It doesnt work for me, look at this.
Code: Select all
global firefox:=new Rufaydium("geckodriver.exe")
global sesion:=firefox.NewSession("C:\Program Files\Mozilla Firefox\firefox.exe")
sesion.Navigate("https://www.google.com.ar")
sesion.WaitForLoad()
sesion.ExecuteSync("asd=300;alert(asd);")
;this alert works well
msgbox, % sesion.ExecuteASync("return asd")
;i cant acces to 'asd' var from ahk, how can i do it?
Following methods are not needed / wrong, as Rufaydium accesses the browser synchronously, it waits for the page to finish loading page there proceeds to the next step, and same goes for
ExecuteASync
1)
sesion.WaitForLoad()
2)
sesion.ExecuteASync("return asd")
3) I suspect Alert() intrups JS
I tested the following code and its working
Code: Select all
#include Rufaydium.ahk
URL := "https://www.autohotkey.com/boards/viewtopic.php?p=470577#p470577"
Page := GetRufaydium(URL)
Page.ExecuteSync("asd=300")
msgbox, % Page.ExecuteSync("return asd")
exitapp
; 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 default 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
}
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory