Issue
I want to store an Xpath
in a variable without having the Webdriver
to execute it.
I want to store it in a variable so that I can use it in an if else statement
var Resetbtn = driver.FindElement(By.XPath("//button[text()='Reset']"));
var Exebtn = driver.FindElement(By.XPath("//button[text()='Exe']"));
if I remove driver I get the following error "The name 'FindElement' does not exist in the current context"
Solution
FindElement
is a method from IWebDriver
. You can store it in a variable, but without parameters. Instead you can store the By
as a variable and send it to FindElement
later
By resetBtnBy = By.XPath("//button[text()='Reset']");
var Resetbtn = driver.FindElement(resetBtnBy);
Answered By - Guy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.