Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get the last message in Google Chrome browser
#12
How to use Selenium IDE web recorder results in LA.

Selenium IDE records a Test. Right-click the test and export as C# xUnit.
Import it into LA. For example drag drop.
In Properties change file type from class to script.

The code is like:
 
Code:
Copy      Help
// script "T1Test.cs"
// Generated by Selenium IDE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Interactions;
using Xunit;
public class SuiteTests : IDisposable {
  public IWebDriver driver {get; private set;}
  public IDictionary<String, Object> vars {get; private set;}
  public IJavaScriptExecutor js {get; private set;}
  public SuiteTests()
  {

    driver = new ChromeDriver();
    js = (IJavaScriptExecutor)driver;
    vars = new Dictionary<String, Object>();
  }

  public void Dispose()
  {

    driver.Quit();
  }
  [
Fact]
  public void T1() {
    driver.Navigate().GoToUrl("https://www.libreautomate.com/");
    driver.Manage().Window.Size = new System.Drawing.Size(1104, 723);
    driver.FindElement(By.LinkText("Forum")).Click();
    driver.FindElement(By.LinkText("Ideas (LA)")).Click();
    driver.FindElement(By.LinkText("LA Context Menu")).Click();
  }
}

Edit:
 
Code:
Copy      Help
// script "T1Test.cs"
/*/ nuget selenium\Selenium.Support; nuget selenium\Selenium.WebDriver.ChromeDriver; /*/
// Generated by Selenium IDE

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Interactions;

using var t = new SuiteTests();
t.T1();

public class SuiteTests : IDisposable {
    public IWebDriver driver { get; private set; }
    public IDictionary<String, Object> vars { get; private set; }
    public IJavaScriptExecutor js { get; private set; }
    public SuiteTests() {
        var service = ChromeDriverService.CreateDefaultService(pathname.getDirectory(typeof(ChromeDriver).Assembly.Location));
        service.HideCommandPromptWindow = true;
        driver = new ChromeDriver(service);
        js = (IJavaScriptExecutor)driver;
        vars = new Dictionary<String, Object>();
    }

    public void Dispose() {
        driver.Quit();
    }

    
    public void T1() {
        driver.Navigate().GoToUrl("https://www.libreautomate.com/");
        driver.Manage().Window.Size = new System.Drawing.Size(1104, 723);
        driver.FindElement(By.LinkText("Forum")).Click();
        driver.FindElement(By.LinkText("Ideas (LA)")).Click();
        driver.FindElement(By.LinkText("LA Context Menu")).Click();
    }
}

If does not work, install or update the 2 NuGet packages. Need to update the NuGet packages for each major Chrome version.
I install Selenium packages in folder "selenium". Edit the first line if installed elsewhere.


Messages In This Thread
RE: How to get the last message in Google Chrome browser - by Gintaras - 03-13-2024, 03:53 PM

Forum Jump:


Users browsing this thread: 5 Guest(s)