ComObjCreate Selenium

Get help with using AutoHotkey and its commands and hotkeys
The_Wildry_Dude
Posts: 9
Joined: 17 Aug 2015, 17:15

ComObjCreate Selenium

15 Dec 2015, 20:30

Hey all,

Just playing around and saw the selenium project. Got it up and running with VBA just as test, and it works well. I could be wrong, but this project appears to be a COM object...?

I tried this, with no success:

Code: [Select all] [Download] GeSHi © Codebox Plus

selDriver := ComObjCreate("SeleniumWrapper.WebDriver")

selDriver.Start("chrome", "http://www.google.ca")
sleep 4000
selDriver.Open("www.google.ca")
selDriver.Type("name=q", "Eiffel Tower")
selDriver.Click("name=btnG")

selDriver.stop


That code errors out line 1. However when I try the following, it does open a new chrome browser however the URL entered is: data:,

Code: [Select all] [Download] GeSHi © Codebox Plus

selDriver := ComObjCreate("{0277FC34-FD1B-4616-BB19-5D556733E8C9}") ; Found this in the registry, not sure if I'm doing this correctly

selDriver.Start("chrome", "http://www.google.ca")
sleep 4000
selDriver.Open("www.google.ca")
selDriver.Type("name=q", "Eiffel Tower")
selDriver.Click("name=btnG")

selDriver.stop


Thanks everyone :)
TheDewd
Posts: 674
Joined: 19 Dec 2013, 11:16
Location: USA

Re: ComObjCreate Selenium

16 Dec 2015, 16:00

Here's an example for Internet Explorer:

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

#SingleInstance, Force
#Persistent

driver := ComObjCreate("Selenium.IEDriver")
driver.Get("http://www.google.com/")
driver.findElementById("lst-ib").sendKeys("Eiffel tower")
driver.FindElementByName("btnG").Click

and Firefox:

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

#SingleInstance, Force
#Persistent

driver := ComObjCreate("Selenium.FirefoxDriver")
driver.Get("http://www.google.ca/")
driver.findElementById("lst-ib").sendKeys("Eiffel tower")
driver.FindElementByName("btnG").Click


Hopefully you get the idea... :-)
malcev
Posts: 49
Joined: 12 Aug 2014, 12:37

Re: ComObjCreate Selenium

26 May 2016, 09:25

Can somebody tell how to use it with autohotkey?
What I have to download and install?
Please!
sjlee128
Posts: 2
Joined: 05 Jun 2016, 03:39

Re: ComObjCreate Selenium

05 Jun 2016, 04:24

Code: [Select all] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus



The code works fine until the msgbox and it prints out "2" because there are 2 query input boxes (one is hidden) on the google image search page
The problem however occurs right on the next line

A quick debugging showed that "object q" is an _WebElements object with guid {0277FC34-FD1B-4616-BB19-7C9763568492}
so I looked it up at
https://github.com/florentbr/SeleniumBa ... lements.cs

[DispId(0), Description("Get the WebElement at the provided index (One-based)")]
WebElement this[int index] { get; }

so there is nothing wrong with the code
I even tried q.this[1] and still the same error
my best guess is that it does not recognize 1 as an integer since variables in ahk don't seem to resolve to a certain type

HELP ME PLEASE!!
malcev
Posts: 49
Joined: 12 Aug 2014, 12:37

Re: ComObjCreate Selenium

05 Jun 2016, 11:17

What do You want to do?
If You want loop through elements with css, You can do it like this:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

hotkeyguy
Posts: 108
Joined: 11 Oct 2014, 12:22

Re: ComObjCreate Selenium

08 Jun 2016, 15:07

Hello,

I was really curious whether it's possible to attach Selenium to a running browser instance, in my case Firefox. Want to use it as a sort of MozRepl. The main answer (no) can be found here: Allow webdriver to attach to a running browser · Issue #18 · SeleniumHQ/selenium-google-code-issue-archive · GitHub. But there are some hints that it is possible (e. g. stackoverflow, binaryclips, binaryclips).


Greetings
hotkeyguy
User avatar
Joe Glines
Posts: 398
Joined: 30 Sep 2013, 20:49
Facebook: https://www.facebook.com/theAutomatorGuru/
Google: https://plus.google.com/105328929654286634910
GitHub: joetazz
Location: Dallas
Contact:

Re: ComObjCreate Selenium

08 Jun 2016, 17:40

I've been playing with the Selenium object over the past couple of days. I've figured out many ways to do much of what we do with COM (but it wasn't as intuitive and also there are lots of different types of syntax which is confusing). I'll probably share some of it early next week.

@HotkeyGuy- I agree it would be great to be able to connect to an existing browser but haven't figured that one out yet! I figured at a minimum I could just have my script launch the browser thru Selenium that way, whatever I happened to be doing, it would already be connected to the object.
enter8
Posts: 96
Joined: 05 May 2016, 16:48

Re: ComObjCreate Selenium

15 Jan 2017, 17:46

My apologies for bumping this old thread, but could someone do a getElementsByClassname in selenium? Everything up to the getelement works, but I can't seem to assign the result to a variable.

Code: [Select all] [Download] GeSHi © Codebox Plus

driver := ComObjCreate("Selenium.FirefoxDriver")
driver.Get("http://www.worldslongestwebsite.com/")
sleep 1500
var1 := driver.getElementsByClassName("footer")[0].innerHTML
msgbox % var1
enter8
Posts: 96
Joined: 05 May 2016, 16:48

Re: ComObjCreate Selenium

16 Jan 2017, 13:37

Joe Glines wrote:Try this
var:=driver.findElementByClass("footer").Attribute("value") ;change "value" to things like OuterHTML, Text, InnerText etc.


So I can't use my browser console-friendly javascript with selenium? That's a bummer. For what it is, it's still pretty nifty, but... I have a hard enough time getting elements via JS, so figuring out something entirely new is a bit daunting.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Miki86big, Terka and 75 guests