Results 1 to 2 of 2

Thread: How to use “action” in vb.net using selenium webdriver?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    5

    How to use “action” in vb.net using selenium webdriver?

    I am using selenium webdriver to automate chrome in VB.net (2019 version). I want to send some keystrokes to chrome using action. I have tried the following code

    Dim driver As IWebDriver
    driver = New ChromeDriver
    driver.Navigate().GoToUrl("https://example.com/")
    Dim action1 As Action = New Action(driver)
    and it is showing me following error at "New action(driver)" location "Delegate "action: requires as "address of" expression or Lambda expression..."

    I have imported the following references

    Imports SileniumTest
    Imports OpenQA.Selenium
    Imports OpenQA.Selenium.Firefox
    Imports OpenQA.Selenium.Chrome
    Imports OpenQA.Selenium.Support.UI
    Imports OpenQA.Selenium.Keys
    Imports OpenQA.Selenium.Interactions.Actions
    Imports OpenQA.Selenium.Interactions
    Please let me know what is causing this error?

    PS: I have tried using this

    Dim element As IWebElement = driver.FindElement(By.Id("userid"))
    element2.SendKeys("xyz" & Keys.Enter)
    This thing works.

    But, I want to use actions because I do not have ID of one text box and I want to mimic keyboard.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: How to use “action” in vb.net using selenium webdriver?

    The use of Action in that context is being interpreted as the System.Action delegate type. If you want to use a different type then you need to qualify the name, e.g.
    vb.net Code:
    1. Dim action1 As New OpenQA.Selenium.Action(driver)
    You don't necessarily need the full namespace, if it is a child of another that you have imported. For instance, if that Action type is a member of OpenQA.Selenium.Interactions.Actions and you have imported OpenQA.Selenium.Interactions, you can do this:
    vb.net Code:
    1. Dim action1 As New Actions.Action(driver)
    Basically, you need to uniquely identify the type so anything that is valid and disambiguates it from System.Action will work.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width