-
Jan 16th, 2021, 12:45 AM
#1
Thread Starter
New Member
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.
-
Jan 16th, 2021, 01:39 AM
#2
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:
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:
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.
Last edited by jmcilhinney; Jan 16th, 2021 at 01:44 AM.
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|