Using Selenium with AutoHotkey- Cross browser automation!

Helpful script writing tricks and HowTo's
User avatar
rizwan4season
Posts: 15
Joined: 13 Nov 2020, 08:37

Re: Using Selenium with AutoHotkey- Cross browser automation!

Post by rizwan4season » 14 Feb 2021, 09:04

I Want to use Edge Browser With Selenium Like a Chorme Browser
Need Help on this topic


burque505
Posts: 1732
Joined: 22 Jan 2017, 19:37

Re: Using Selenium with AutoHotkey- Cross browser automation!

Post by burque505 » 15 Feb 2021, 12:44

Just found a SeleniumBasic for Selenium v3.141.000. Here is the link in Chinese(Mandarin?).
My own Mandarin is next to useless, so perhaps others in the forum can be of help. However, just using Google Translate gives a lot of clues.
It has reg and unreg .bat files.
I will now try to destroy my system by installing it. :crazy: I'm curious to see if it might be a significant improvement.

EDIT: This seems very useful indeed. It can control IE, Chrome, Edge (@rizwan4season, this might be worth a look), Opera and Safari out of the box, apparently. I will work on posting something in Ask for Help and Scripts and Functions. The Javascript execution seems to be quite good. It is easy to pass in arguments from the calling script and to return variables from the Javascript call. Async appears to work, unlike SeleniumBasic v2. I have had no success so far getting it to accept Selenium-style Keys.[Key] (i.e. Keys.Enter, Keys.Backspace, Keys.numpad0) from IWebElement.SendKeys(string), but strings themselves work fine. I am for now working around it with "Send, {Enter}" and so on.

Given "svc := ComObjCreate("SeleniumBasic.ChromeDriverService")", "svc.HideCommandPromptWindow := True" runs the script with a hidden command window. Very helpful.

Download link: https://files.cnblogs.com/files/ryueifu-VBA/SeleniumBasic.zip

EDIT: So far so good.

Code: Select all

wd := ComObjCreate("SeleniumBasic.IWebDriver")

si(wd)
wd.New_ChromeDriver
wd.URL := "https://www.autohotkey.com"
msgbox Got it.
wd.Quit
wd := ""

si(d) {
VarType := ComObjType(d)
IName   := ComObjType(d, "Name")
IID     := ComObjType(d, "IID")
CName   := ComObjType(d, "Class")  ; Requires [v1.1.26+]
CLSID   := ComObjType(d, "CLSID")  ; Requires [v1.1.26+]
MsgBox % "Variant type:`t" VarType
	. "`nInterface name:`t" IName "`nInterface ID:`t" IID
	. "`nClass name:`t" CName "`nClass ID (CLSID):`t" CLSID
}
Regards,
burque505
Last edited by BoBo on 18 Feb 2021, 17:39, edited 2 times in total.
Reason: Fixed broken download link. HTH

Milchmann
Posts: 112
Joined: 05 Nov 2016, 08:50

Re: Using Selenium with AutoHotkey- Cross browser automation!

Post by Milchmann » 20 May 2021, 07:09

Google Chrome greater version 88 brings problems with all my applications, respectively only small parts of them work. Is this also the case for you?

Is there an alternative?


Thanks
Last edited by Milchmann on 20 May 2021, 07:36, edited 1 time in total.

gregster
Posts: 8990
Joined: 30 Sep 2013, 06:48

Re: Using Selenium with AutoHotkey- Cross browser automation!

Post by gregster » 20 May 2021, 07:12

Milchmann wrote:
20 May 2021, 07:09
Please use english (or the respective language of the subforum) in the non-german sections of the forums.
You can edit your post above.

burque505
Posts: 1732
Joined: 22 Jan 2017, 19:37

Re: Using Selenium with AutoHotkey- Cross browser automation!

Post by burque505 » 20 May 2021, 07:40

@Milchmann, you might take a look at this topic. It pertains to v90 with Chrome.ahk, but it seems paths are handled differently in newer versions of Chrome.

Milchmann
Posts: 112
Joined: 05 Nov 2016, 08:50

Re: Using Selenium with AutoHotkey- Cross browser automation!

Post by Milchmann » 23 May 2021, 04:52

That is not the solution. For example, the following commands no longer work from Google Chrome > 88:

Code: Select all

.SendKeys("
.click()
driver.Actions.ClickDouble("w2342424").Perform
.findElementsByTag("tr")

Is there a workaround to make these commands work properly again?
Or is it just me using Selenium Basic?

Thank you

burque505
Posts: 1732
Joined: 22 Jan 2017, 19:37

Re: Using Selenium with AutoHotkey- Cross browser automation!

Post by burque505 » 23 May 2021, 07:01

@Milchmann, I'm not experiencing those problems with SeleniumBasic and Chrome v90.

User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Using Selenium with AutoHotkey- Cross browser automation!

Post by Xtra » 23 May 2021, 16:53

burque505 wrote:
23 May 2021, 07:01
@Milchmann, I'm not experiencing those problems with SeleniumBasic and Chrome v90.
+1
Just confirming no issues here either i have multiple projects using it atm.

Milchmann
Posts: 112
Joined: 05 Nov 2016, 08:50

Re: Using Selenium with AutoHotkey- Cross browser automation!

Post by Milchmann » 26 May 2021, 06:20

Does not work for me with the following function:
I need the manual start with



Code: Select all

run,  chrome.exe --user-data-dir=C:\Temp\Chrome\Cache\cache\Default  --remote-debugging-port=9222
chromeGet()
sleep, 3000

driver.findElementsByClass("f1").item[A_Index].click()
return



ChromeGet(IP_Port := "127.0.0.1:9222") 
{
driver := ComObjCreate("Selenium.ChromeDriver")
driver.SetCapability("debuggerAddress", IP_Port)
driver.Start()
return driver
}

because I repeatedly call several sub-programs with chromeGet (). I also continue to work with it in various TABs.

How can I achieve that I can continue working with this method> Chrome 88. Is there a script for that? To make matters worse, I don't have administrator rights on the computer.

Thanks

User avatar
Thoughtfu1Tux
Posts: 125
Joined: 31 May 2018, 23:26

Re: Using Selenium with AutoHotkey- Cross browser automation!

Post by Thoughtfu1Tux » 05 Jun 2021, 08:53

I'm having a ton of issues with Chrome 91 as well. I can send to a page, but i cannot read the contents from a page half the time, be it with name,id, or xpath.

Anyone else having this issue?

burque505
Posts: 1732
Joined: 22 Jan 2017, 19:37

Re: Using Selenium with AutoHotkey- Cross browser automation!

Post by burque505 » 05 Jun 2021, 11:17

@Thoughtfu1Tux, if you installed SeleniumBasic (the old version) in Program Files, you might try downloading the chromedriver.exe for v91 and putting it the program folder. I'm not having any unusual issues with Chrome 91 at the moment. No issues with SeleniumBasic v3.141.00 (see my post above or this topic) either, although the webdriver lives in a different folder for the scripts I have using that.
Regards,
burque505

nik2502
Posts: 4
Joined: 15 Jun 2020, 09:00

Re: Using Selenium with AutoHotkey- Cross browser automation!

Post by nik2502 » 25 Oct 2021, 07:23

Hi,

Thanks a lot for all the help with Selenium and AutoHotKey ! :)

Would like to know if its possible to set up Selenium grid too with AHK ?

Post Reply

Return to “Tutorials (v1)”