Click here to Skip to main content
15,069,838 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a VB windows forms project using Selenium Web Driver in VS 2017 .net 4.6.1. It works fine when using Chrome Driver. But I can't load Firefox. Can someone get me started in how to connect to Firefox?

What I have tried:

I have found several procedures on the web. None of them work for VB. Most procedures I found are for C#, But I can't translate them to VB. I believe I loaded all the NuGet packages required.
Posted
Comments
Richard Deeming 20-Feb-18 15:00pm
   
How about showing us the C# code, and your attempt to convert it to VB.NET, and explaining where you're stuck?
BobbyStrain 20-Feb-18 15:17pm
   
Here is the C# code I can't convert to VB. I can't find any VB equivalent. Apparently this is the method now required for the latest Firefox.

public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver","D:\\Firefox\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
}
Richard Deeming 20-Feb-18 15:19pm
   
Public Shared Sub Main()
    System.setProperty("webdriver.gecko.driver", "D:\Firefox\geckodriver.exe")
    Dim driver As WebDriver = New FirefoxDriver()
    driver.get("http://www.google.com")
End Sub

If that doesn't work, then make sure you've imported all of the required namespaces:
C#: using SomeNamespace;
VB: Imports SomeNamespace
BobbyStrain 21-Feb-18 17:29pm
   
Richard, I began the build in C# and I didn't need this "setProperty" at all. And I found Tellerick's code converter to help the VB --> C# conversion. And, thanks again for your help. I hope I don't have to convert my whole website to C#, 10 years in the making.
BobbyStrain 24-Feb-18 21:22pm
   
Richard, I have progressed a bit in converting to C#. Most things work well. However, when i manually click a button and activate java script that writes to a hidden input as well as a label on the page, the Firefox driver loses the connection. Chrome with VB works OK. I wonder where I can look to resolve this issue? Thanks for your help.
BobbyStrain 20-Feb-18 18:14pm
   
Richard, thank you for your help. It seems that there is a special library required to use Selenium with VB. It still works with Chrome, but not Firefox which needs the newest versions. There is no setProperties method in VB as there is in C#. So, if I want to use Selenium with anything other than Chrome, I will have to convert to C#. Eventually, Chrome will go to the newer version, too. It's not much code, but it is necessary to fill some web forms on my site and to save the info, too. Maybe I'll look at moving a desktop application to the cloud instead.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900