ChromeDriver - WebDriver for Chrome

ChromeDriver - WebDriver for Chrome

Postby Horizon » Sun Aug 30, 2020 9:09 am

Hi,

Is there anybody to use it from harbour?

Thanks.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: ChromeDriver - WebDriver for Chrome

Postby Horizon » 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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: ChromeDriver - WebDriver for Chrome

Postby Horizon » Fri Sep 04, 2020 9: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: Select all  Expand view
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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: ChromeDriver - WebDriver for Chrome

Postby Horizon » Tue Sep 08, 2020 2: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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: ChromeDriver - WebDriver for Chrome

Postby anserkk » Thu Jan 19, 2023 5: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/SeleniumBa ... g/v2.0.9.0

They have provided the source codes too but it is in C#
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: ChromeDriver - WebDriver for Chrome

Postby anserkk » Thu Jan 19, 2023 6: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: Select all  Expand view
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


Image
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: ChromeDriver - WebDriver for Chrome

Postby Antonio Linares » Thu Jan 19, 2023 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ChromeDriver - WebDriver for Chrome

Postby anserkk » Thu Jan 19, 2023 8: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: Select all  Expand view
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

Image

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

The same code in Vbscript is working ie
Code: Select all  Expand view
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.
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: ChromeDriver - WebDriver for Chrome

Postby Jimmy » Fri Jan 20, 2023 9: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: Select all  Expand view
// 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: Select all  Expand view
regasm test.dll /unregister
csc /t:library test.cs
::csc /t:library /debug:full /debug+ %1.cs
regasm test.dll


on Xbase++ Side

Code: Select all  Expand view
#pragma library( "ascom10.lib" ) // Xbase++ LIB for ActiveX

proc main()
local oAX

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

return
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: ChromeDriver - WebDriver for Chrome

Postby anserkk » Sat Jan 21, 2023 4:07 am

Thank you for this information :)
This opens a lot of possibilities for integration with Fivewin/Harbour.
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 56 guests