Can't use Selenium with the Company Modified Browser - excel

The Company change the browser name to XYZFirefox.exe . And since then, my code is getting an error. "Failed to locate Firefox.exe in the registry". I'm trying it again with the simple code. Does renaming the exe affects it? I would like to sort this first before mailing our IT Dept. Thanks
Dim bot As New FirefoxDriver
Dim url As String
url = "https://google.com"
bot.Get url

You can specify a path to binary:
Dim bot As New FirefoxDriver
bot.SetBinary("path to your custom Firefox")

Related

VBA Selenium with Chrome - Upload a file to the WebPage

I am using VBA to automate Chrome to upload a file to a site, with the button of File type
I have no idea about uploading script in chrome
My current VBA:
Sub UploadFile()
Dim bot As WebDriver
Set bot = New WebDriver
bot.Start "chrome"
bot.Get "https://tutorialehtml.com/en/html-tutorial-upload-form/"
'#continue script here please"
End Sub
If there is any input field with attribute type = 'file' you can use the below code :
bot.FindElementByCss("input[type='file']").SendKeys "path of file"

VBA Selenium cannot find chrome binary

I am trying to open Chrome with Selenium but when I run the code I get an error message stating:
Cannot find Chrome library.
Sub driver()
Dim selenium As New selenium.WebDriver
selenium.Start "chrome", "http://google.com"
selenium.Get "/"
End Sub
I have installed the latest version of Selenium, and updated the Chromedriver. I think the problem is that Chrome.exe is not in the location selenium expects it to be. Does anybody know how to change the path to Chrome.exe?

Selenium type library can't find file driver.start "chrome","https://www.google.com"

I want to use Excel VBA with Selenium Wrapper to launch Google Chrome and then control Chrome to serve pages I specify so that I can scrape data from them. I can't launch Chrome from VBA.
I'm running Excel 2010. In VBA editor I have added Selenium Type Library to the references. I've verified that I'm running ChromeDriver 2.33.506120. In the code below I know driver is recognized as a driver because I'm getting Intellisense options. I have the ChromeDriver in a folder in Program Files. I have set this folder in the Path list. When I run the code, I get: Run Time Error 2147024894, Automation Error, The system cannot find the file specified. I have also tried driver.start with same results. I have tried changing the name of the browser to "Google Chrome".
Sub MyTest()
Dim driver As New ChromeDriver
driver.Get "https://www.google.com"
End Sub
I expected to launch Chrome. What I get is an error message.
Error Message

Receiving KeyNotFoundError Dictionary key not found: status when using the .click method

I'm currently trying to learn VBA in Excel and I've written a simple procedure where I should be able to launch Chrome and click on a button. Problem is that I'm getting a Run-time error '0': KeyNotFoundError Dictionary key not found:status whenever I try to use the .click method.
I downloaded the Selenium Basic from the following site https://florentbr.github.io/SeleniumBasic/ activated the reference in VBA and downloaded the latest chromedriver
Sub driver()
Dim driver As New Selenium.WebDriver
Set driver = New Selenium.WebDriver
driver.Start "chrome"
driver.Get "http://www.google.com"
Set Element = driver.FindElementByName("btnI")
Element.Click
End Sub
This is just a simple code where I launch Chrome and go to Google and click the "I feel Lucky" button.
A quick test for firing that button and I needed to use javascript
driver.ExecuteScript "document.querySelector('[name=btnI]').click();"
If the error remains I suggest checking chromedriver.exe is the right version for your Chrome browser and do a selenium re-install and check the selenium type reference as usual in the VBE.
The latest version of Chrome is throwing "KeyNotFoundError Dictionary key not found:status" error.
Try replacing your Chromedriver with version 2.46. Here is the link: https://chromedriver.storage.googleapis.com/index.html?path=2.46/
Below is the code I have tried and it worked perfectly fine for me. Let us know if this solution worked for you! :)
Sub driver()
Dim driver As New Selenium.WebDriver
Set driver = New Selenium.WebDriver
driver.Start "chrome"
driver.Get "http://www.google.com"
driver.FindElementByCss("#tsf > div:nth-child(2) > div > div.FPdoLc.VlcLAe > center > input[type=submit]:nth-child(2)").Click
End Sub

Interact with Google Chrome on VBA

From an excel file in VBA, I would like to click on the big button on this webpage (https://www.ilovepdf.com/jpg_to_pdf), select a file from my computer to download to this website (select the right path), validate, download the new file, then close the tab.
I have for the moment manage to open the browser but I can interact with the website..
Thanks for your help :)
Sub ConvertFile()
ChromeLocation = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" 'Location of Chrome.exe in your PC
MyURL = "https://www.ilovepdf.com/jpg_to_pdf" 'URL that you would like to open; you may also use a variable for this, or a pointer to the location of the URL
Shell (ChromeLocation & " -url " & MyURL)
End Sub
You could use selenium basic to launch and interact with chrome. I am showing how to launch, enter a search term, and click a button. The rest of your question is simply too broad. The example will bring up the download site in the search results. After installation you will need to add a reference to selenium type library.
Option Explicit
Public Sub Demo()
Dim d As WebDriver
Set d = New ChromeDriver
Const URL = "https://www.google.com/"
With d
.Start "Chrome"
.get URL
.FindElementById("lst-ib").SendKeys "Selenium basic GitHub"
.FindElementsByTag("form")(1).FindElementByCss("input[value='Google Search']").Click
'.Quit
End With
End Sub

Resources