Home > other >  C# to VB.net conversion About the Selenium waits Example
C# to VB.net conversion About the Selenium waits Example

Time:01-25

I can't figure out how to convert this code in the example text. How should I write it?

wait.Until(e => e.FindElement(By.XPath("//a/h3")));

Original Site : Wait | Selenium

Original Code :

driver = new ChromeDriver();
driver.Url = "https://www.google.com/ncr";
driver.FindElement(By.Name("q")).SendKeys("cheese"   Keys.Enter);
 
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IWebElement firstResult = wait.Until(e => e.FindElement(By.XPath("//a/h3")));

Console.WriteLine(firstResult.Text);

Ps. I would like to know the following as well

var foo = new WebDriverWait(driver, TimeSpan.FromSeconds(3))
                    .Until(drv => drv.FindElement(By.Name("q")));

.Until: ■ Function DfaultWait(Of IwebDriver).Until(Of TResult)(condition As Func(Of IWebDriver, TResult))As TResult ( 1 overload)

Thank in Advance

ーーーーーーーーーーー

▼ I am glad to inform you that the problem is now solved.

Dim firstResult As IWebElement = Wait.Untile(Function(e) e.findElement(By.XPath("//a/h3")))

Thanks for replying.

CodePudding user response:

This

wait.Until(e => e.FindElement(By.XPath("//a/h3")));

is this

wait.Until(Function(e) e.FindElement(By.XPath("//a/h3")))
  •  Tags:  
  • Related