Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Facing issue with Selenium version 4 and above with VFP

Premal Vala

Programmer
Jul 10, 2024
10
IN
Dear Experts,

I am using Selenium with VFPA via C# dll. I have created COM DLL with C# within VSS. I am using it successfully once registered with REGASM. However my problem is with Selenium .WebDriver and Selenium.Support version. My DLL and automation is working fine when I am using Selenium version 3.5.2. See below:



1735125968122.png


But as soon as I try to update this version to latest or even to 4.0.0. VFPA starts giving error on automation.

Can anyone help what is wrong with Selenium Latest version and VFPA?

Thanks in advance.
PREMAL VALA
 
I have created COM DLL with C# within VS
Source code of that? Since you're using Selenium through this DLL that's the point of failure, isn't it? So not knowing how you create a selenium object in your c# code, how should we be able to help with what's going on?
 
Hey Chris,

My bad on not providing details, here it is.

Below is my C# code:
C#:
using OpenQA.Selenium.Chrome;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace TestDll
{
    [ClassInterface(ClassInterfaceType.AutoDual)]
    [ProgId("MyTest")]
    [ComVisible(true)]

    public class Class1
    {
        public string MyAuto()
        {
            ChromeOptions passOptions = new ChromeOptions();

            passOptions.AddExcludedArgument("enable-automation");
            passOptions.AddUserProfilePreference("credentials_enable_service", false);
            passOptions.AddUserProfilePreference("profile.password_manager_enabled", false);

            var driverService = ChromeDriverService.CreateDefaultService();
            driverService.HideCommandPromptWindow = true;


            ChromeDriver passDriver = new ChromeDriver(driverService, passOptions);
            passDriver.Url = "https://www.google.com";
            Thread.Sleep(3000);
            passDriver.Quit(); 

            return "Auto";
        }

    }
}

I generate and register DLL from this and use following VFP Code:

Code:
myobj = CREATEOBJECT("MyTest")
?myobj.MyAuto()
It works fine with Selenium version 3.5.2 but not with any later version than 3.5.2. It shows below error as soon as I update selenium version:

1735131511150.png

Hope this helps everyone to provide some help.

Thanks again.
 
Code:
using OpenQA.Selenium.Chrome;
For this line you'll have a refernce in your c# project- After upgrading Selenium, did you change the reference to the new Selenium version? Otherwewise you refer to a not anymore existing assembly that causes that error.

In short what I'm saying is if you reference some assembly in a VS.NET project you refer to one very specific assmbly and its version. You expect this to work forever without updates, that's what's wrong. Upgrade your DLL, the code might not need any adjustment, but the reference of the assembly you link to has to change.
 
Last edited:
Hi Chris,

Thanks again for your response. But I am updating the selenium within the VS.Net project with NuGET package, which means references are automatic updated.

Also, I tried creating a DLL from completely new project of VS.NET with newer version at first go but that to leads to the same result.

Thanks,
PREMAL
 
Seems to be an issue of the binding to System.Text.Json and that might be an issue because of which .NET Framework version your project is based on.
 

Part and Inventory Search

Sponsor

Back
Top