FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ChromeDriver - WebDriver for Chrome
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
ChromeDriver - WebDriver for Chrome
Posted: Sun Aug 30, 2020 09:09 AM

Hi,

Is there anybody to use it from harbour?

Thanks.

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: ChromeDriver - WebDriver for Chrome
Posted: Sun Aug 30, 2020 10:42 AM

Hi,

We have to download chromedriver from https://chromedriver.chromium.org/downloads and copy it to pathed directory.
(https://chromedriver.chromium.org/getting-started)

To use it, We should download Selenium webdriver from https://www.selenium.dev/downloads/.

Next step is that run chromedriver using selenium webdriver and open any web site from application.

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: ChromeDriver - WebDriver for Chrome
Posted: Fri Sep 04, 2020 09:25 AM
Hi,

In order to test Selenium library. I have installed Visual Studio 2019 using C# by using this link https://testguild.com/selenium-webdriver-visual-studio/.

This is the latest C# code.
Code (fw): Select all Collapse
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;

namespace mySelenium
{
    class Program
    {
        static void Main(string[] args)
        {
            //!Make sure to add the path to where you extracting the chromedriver.exe:
            IWebDriver driver = new ChromeDriver(@"C:\WebDriver\bin"); //<-Add your path
            driver.Navigate().GoToUrl("http://forums.fivetechsupport.com/viewforum.php?f=3");

//            IWebElement myField = driver.FindElement(By.Id("btn red-flamingo"));
//            IWebElement myField = driver.FindElement(By.ClassName("red-flamingo"));
//            myField.Click();

//            myField = driver.FindElement(By.Name("tridField"));
//            myField.SendKeys("3333");

//            myField = driver.FindElement(By.Name("egpField"));
//            myField.SendKeys("4444");

            
//            myField = driver.FindElement(By.ClassName("submitButton"));
//            myField.Click();

 
            Thread.Sleep(15000);
            driver.Quit();
        }
    }
}


This code is opens a new chrome browser page and sleep 15 second than close it.

Next step, Can anyone help me to call it from Harbour?

Thanks.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: ChromeDriver - WebDriver for Chrome
Posted: Tue Sep 08, 2020 02:59 PM

Hi,

I build test project in c# msvc 2019. in the build folder, there is a Webdriver.dll file.

How to create lib file from this dll?

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: ChromeDriver - WebDriver for Chrome
Posted: Thu Jan 19, 2023 05:11 AM
Was there any progress on this ?

There is also a Selenium based browser automation framework for VB.Net, VBA and VBScript
https://florentbr.github.io/SeleniumBasic/

I believe that, If SeleniumBasic can be used via VBScript then it should be possible with Fivewin too.

This is a handy tool for Web browser automation. For eg. Programmatically you can log in to a website, fill in the username and password via our Fivewin, then search for specific data, fetch the data from the HTML table to Excel etc all these processes can be done in an automated manner.

Has anybody here already done this using SeleniumBasic ?

Here is the link to download the tool
https://github.com/florentbr/SeleniumBasic/releases/tag/v2.0.9.0

They have provided the source codes too but it is in C#
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: ChromeDriver - WebDriver for Chrome
Posted: Thu Jan 19, 2023 06:58 AM
I tried to create a Lib from the DLL using implib. Unfortunately, the size of the created lib is just 1 KB. Is that normal. ?

While trying to do the implib this is the message that I got
Code (fw): Select all Collapse
D:\bcc7\bin\implib -a Selenium.lib Selenium.dll

Embarcadero Implib Version 3.3.0 Copyright (c) 1991-2014 Embarcadero Technologies, Inc.
Warning Selenium.dll: no exports
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ChromeDriver - WebDriver for Chrome
Posted: Thu Jan 19, 2023 07:35 AM

Dear Anser,

It seems as it is a .NET DLL.

You can use FWH WebView to do Web browser automation.

Please review FWH\samples\webviewuni.prg

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: ChromeDriver - WebDriver for Chrome
Posted: Thu Jan 19, 2023 08:52 AM
OK. Thank you :)

I thought that something that can be accessed via VBA or VBScript can be used by Harbour too

A COM library to use Selenium with Excel in the Visual Basic Editor or within a visual basic script (VBS). That's what they have mentioned.

This Selenium has extensive inbuilt features, for eg to export HTML tables to Excel etc.
Code (fw): Select all Collapse
Function TestSelenium()

    Local oSel, oPost, aData:={}
    
    oSel := CreateObject("Selenium.ChromeDriver")
    oSel:Start("chrome")
    Sleep(500)
    // Works fine till here. It opens Chrome with a label "The Chrome is being controlled by automated test software"
    // next it has to open the website. As per the documentation
    // we should call Get("URL")

    // Fails at the next line. Says no  exported method https://www.google.co.in    
    oSel:Get( "https://www.google.co.in" ) // Fails here a

    oSel:Quit()
Return


I assumed that the failure was because I have not static linked the DLL

The same code in Vbscript is working ie
Code (fw): Select all Collapse
Set oSel = CreateObject("Selenium.ChromeDriver")

oSel.Get "https://accounts.google.com/ServiceLogin"
oSel.FindElementById("identifierId").SendKeys "MyEmailId@gmail.com"
Antonio Linares wrote: You can use FWH WebView to do Web browser automation.
Shall try that.
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: ChromeDriver - WebDriver for Chrome
Posted: Fri Jan 20, 2023 09:07 PM
hi,

to use DotNet DLL you need to make a "C-Wrapper" using iDispatch Interface

here a Sample which i have used under Xbase++
Code (fw): Select all Collapse
// sample from http://www.codeproject.com/dotnet/nettocom.asp

using System;
using System.Runtime.InteropServices;

namespace Tester
{
    [Guid("D6F88E95-8A27-4ae6-B6DE-0542A0FC7039")]
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    public interface _Numbers
    {
        [DispId(1)]
        int GetDay();
        
        [DispId(2)]
        int GetMonth();

        [DispId(3)]
        int GetYear();

        [DispId(4)]
        int DayOfYear();
    }

    [Guid("13FE32AD-4BF8-495f-AB4D-6C61BD463EA4")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("Tester.Numbers")]
    public class Numbers : _Numbers
    {
        public Numbers(){}
        
        public int GetDay()
        {
            return(DateTime.Today.Day);
        }

        public int GetMonth()
        {
            return(DateTime.Today.Month);
        }

        public int GetYear()
        {
            return(DateTime.Today.Year);
        }

        public int DayOfYear()
        {
            return(DateTime.Now.DayOfYear);
        }
    }
}
compile with MSVC call
Code (fw): Select all Collapse
regasm test.dll /unregister
csc /t:library test.cs
::csc /t:library /debug:full /debug+ %1.cs
regasm test.dll
on Xbase++ Side
Code (fw): Select all Collapse
#pragma library( "ascom10.lib" ) // Xbase++ LIB for ActiveX 

proc main()
local oAX

   oAX := CreateObject("Tester.Numbers")
   ? oAX:getDay()

return
greeting,

Jimmy
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: ChromeDriver - WebDriver for Chrome
Posted: Sat Jan 21, 2023 04:07 AM
Thank you for this information :)
This opens a lot of possibilities for integration with Fivewin/Harbour.

Continue the discussion