Page 7 of 9

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 25 Oct 2019, 13:16
by burque505
@malcev, thanks for the clarification.

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 25 Oct 2019, 13:37
by burque505
Thanks, malcev. As others have complained of on StackOverflow, the supplied SeleniumBasic.chm file is corrupt. I didn't see any other API documentation in the folder.

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 25 Oct 2019, 13:52
by malcev
Strange. For me this file works on both systems: Win7 and Win10.

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 25 Oct 2019, 14:00
by burque505
Perhaps it's a question of encoding. I haven't tried with Win10 yet, but I will. Might I ask what codepage your system is?

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 25 Oct 2019, 14:07
by malcev
IsSingleByte : True
BodyName : koi8-r
EncodingName : Cyrillic (Windows)
HeaderName : windows-1251
WebName : windows-1251
WindowsCodePage : 1251
IsBrowserDisplay : True
IsBrowserSave : True
IsMailNewsDisplay : True
IsMailNewsSave : True
EncoderFallback : System.Text.InternalEncoderBestFitFallback
DecoderFallback : System.Text.InternalDecoderBestFitFallback
IsReadOnly : True
CodePage : 1251

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 25 Oct 2019, 14:14
by burque505
Большое спасибо! As it turns out, I was able to open it from the command prompt with

Code: Select all

C:\temp> hh Selenium.chm
I don't recall this happening before, that I had to do that, that is. Double-clicking a *.chm file generally opens the file for me. At any rate, thanks again, and the mystery is solved! And the file is very helpful indeed.
Regards,
burque505

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 26 Oct 2019, 04:46
by daiweisc
malcev wrote:
25 Oct 2019, 05:52
@gregster, did You ever use selenium wrapper for vba? And if Yes, where did You find this methods: AddExperimentalOption, ChromeOptions?
@daiweisc, preferences You can set with WebDriver.SetPreference Method.
@gregster, thank your reply soon, i will try it on Monday.
@malcev, thank your conclusion, i think it will be simple for use, but i am confused with WebDriver.SetPreference and WebDriver.AddArgument? what is the difference of WebDriver.SetPreference and WebDriver.AddArgument?

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 26 Oct 2019, 05:27
by malcev

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 26 Oct 2019, 14:14
by euras
hi, can Selenium be accessed only from Debug mode browser, or can I access the page from the active browser, usin Selenium, no mater what?

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 26 Oct 2019, 19:18
by daiweisc
malcev wrote:
26 Oct 2019, 05:27
Preferences:
https chromium.googlesource.com /chromium/src/+/master/chrome/common/pref_names.cc Broken Link for safety
Arguments:
https chromium.googlesource.com /chromium/src/+/master/chrome/common/chrome_switches.cc Broken Link for safety
in Edge and Firefox ,I want to use the function of "ask where to save each file before downloading", just like Chrome code :

Code: Select all

prefs := """download.prompt_for_download"": True"		; or prefs := "'download.prompt_for_download': True"
options.AddExperimentalOption("prefs", prefs)
How to write the code in Edge and Firefox ?

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 27 Oct 2019, 05:37
by malcev
@euras, read this topic from the start.
@daiweisc,
1) Code that You provided will not work.
2) Boolean value true in Com is not just "true" or 1, but ComObject(0xB, -1).
3) You can search for Edge and Firefox preferences by Yourself.

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 28 Oct 2019, 02:07
by daiweisc
malcev wrote:
27 Oct 2019, 05:37
@euras, read this topic from the start.
@daiweisc,
1) Code that You provided will not work.
2) Boolean value true in Com is not just "true" or 1, but ComObject(0xB, -1).
3) You can search for Edge and Firefox preferences by Yourself.
thanks, i run this code works well

Code: Select all

Driver := ComObjCreate("Selenium.ChromeDriver")           ; Start with Chrome
Driver.SetPreference("download.prompt_for_download", ComObject(0xB, -1))
Driver.AddArgument("--start-maximized")

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 28 Oct 2019, 22:05
by daiweisc
i automate the web hover menu with selenium.
the code is :

Code: Select all

Driver.FindElementByCSS("#divMenu > ul > li:nth-child(7) > a").ClickAndHold()
Sleep,500
Driver.FindElementByCSS("#divMenu > ul > li:nth-child(7) > ul > li:nth-child(1) > a").Click()
Sleep,1000
sometimes the code does work, sometimes works wrong. this make me confused. Who can help me?
the wrong is missing element.

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 29 Oct 2019, 03:14
by daiweisc
Sir Teddy the First wrote:
06 Oct 2019, 03:05
@Xtra
I'm using Microsoft Edge (EdgeHTML) version 18 and thats the problem because you can only download the drivers up to version 17, version 18 needs to be installed through the command window so I don't get an .exe-file that I could copy to the SeleniumBasic Folder.
That is my problem.

I already tried downloading the version 17 file. The .exe-file can be started without a problem but when trying to access that driver via AHK I still get a timeout message.
I can not use Edge well,how do you access the driver via AHK. I downloads the Edge WebDriver and copy it to the SeleniumBasic Folder. But it does not work.

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 11 Nov 2019, 02:10
by chngrcn

Code: Select all

<a href="javascript:void(0)" data-id="26b60b16-f60b-4ea0-b439-2bbc5bd6dc08" data-what="getEgmPlakaQ" class="btn btn-dark"><i class="fa fa-spinner" aria-hidden="true"></i> Detail</a>
I would like to click the button named "Detail" in the html code above. but the following code doesn't work.
I use selenium. Can you help me. Thank you.

Code: Select all

driver.executeScript("return document.all('26b60b16-f60b-4ea0-b439-2bbc5bd6dc08').click()")
this code does not work. somehow failed!


https://imgyukle.com/i/ekran-alintisi.Ew2qoH

Can you help me. Thank you.

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 22 Nov 2019, 08:42
by blue83
Hi why is there need for .NET Framework 3.5?

I have 4.0 and above, and no admin rights for instalation, how to solve this?

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 31 Mar 2020, 17:52
by robo_z
How to Translate this:


Select oSelect = new Select(driver.findElement(By.id("yy_date_8")));

oSelect.selectByVisibleText("2010");


to autohotkey to use with Selenium.

this code is for select a element from a listview

Thanks.

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 31 Mar 2020, 18:35
by malcev
Search doc for asselect method.

Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 18 Jun 2020, 01:56
by Thoughtfu1Tux
I was playing around with burque505's PDF code that he posted in 2019 and managed to dig up a way to take a screenshot of the page thanks to this wonderful StackOverflow answer: https://stackoverflow.com/questions/60992134/seleniumbasic-vba-takescreenshot-element-outside-of-the-screenshot-error?r=SearchResults

Code: Select all


driver:= ComObjCreate("Selenium.CHROMEDriver") ;Select and Create Chrome driver instance
driver.setbinary("C:\Software\Chromium\chrome.exe")	;Sets path to custom Binary

driver.AddArgument("disable-infobars") ;Hides 'Chrome is being controlled by automated test software' message
driver.AddArgument("--start-maximized") ; Maximize Chrome Browser
driver.AddArgument("--disable-gpu")
;driver.AddArgument("--headless")
driver.get("https://www.startpage.com")
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
;driver.Window.Maximize	; Maximize the window, not really necessary as chrome starts that way by default


savepath = C:\Users\%A_UserName%\Downloads\StartpageScreenshot.png
driver.TakeScreenshot().SaveAs(savepath)

run, %savepath%	; Open screenshot
Msgbox, Screenshot taken!

ExitApp


Re: Using Selenium with AutoHotkey- Cross browser automation!

Posted: 18 Jun 2020, 13:22
by burque505
Thanks, @Thoughtfu1Tux! Here's a version using SChrome_Get by @AHK_User with credits to @tmplinshi, @CH HAN and @Joe Glines.

Code: Select all

#Include SChrome_Get.ahk

driver := SChrome_Get("https://chromium.woolyss.com/")
driver.AddArgument("disable-infobars") ;Hides 'Chrome is being controlled by automated test software' message
driver.AddArgument("--start-maximized") ; Maximize Chrome Browser
driver.AddArgument("--disable-gpu")
;driver.AddArgument("--headless")

driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
;driver.Window.Maximize	; Maximize the window, not really necessary as chrome starts that way by default

savepath = %A_ScriptDir%\ChromiumScreenshot.png
driver.TakeScreenshot().SaveAs(savepath)

run, %savepath%	; Open screenshot
Msgbox, Screenshot taken!

ExitApp
EDIT: Seems to work fine like this as well.

Code: Select all

#Include SChrome_Get.ahk
driver := SChrome_Get("https://chromium.woolyss.com/")
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
;driver.Window.Maximize	; Maximize the window, not really necessary as chrome starts that way by default
savepath = %A_ScriptDir%\ChromiumScreenshot.png
driver.TakeScreenshot().SaveAs(savepath)
run, %savepath%	; Open screenshot
Msgbox, Screenshot taken!
ExitApp
RE-EDIT:

This scrolls the nav footer into view before taking the screenshot.

Code: Select all

#Include SChrome_Get.ahk
driver := SChrome_Get("https://www.amazon.com/")
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
driver.FindElementById("navFooter").ScrollIntoView()
;driver.Window.Maximize	; Maximize the window, not really necessary as chrome starts that way by default
savepath = %A_ScriptDir%\ChromiumScreenshot.png
driver.TakeScreenshot().SaveAs(savepath)
run, %savepath%	; Open screenshot
Msgbox, Screenshot taken!
ExitApp
Regards,
burque505