c# - WebDriver i am trying to use isElementPresent but error shows not exist in the current context -


i new webdriver , writing code in c# visual studio (code snippet below) verifying if text field present on home page using iselementpresent. error name iselementpresent not exist in current context. doing wrong?

using system; using system.text; using system.text.regularexpressions; using system.collections.generic; using system.threading; using system.linq; using nunit.framework; using openqa.selenium; using openqa.selenium.firefox; using openqa.selenium.support.ui;  namespace homepage_check2 {     [testfixture]     public class driver     {         iwebdriver driver;          [setup]         public void setup()         {             // create new instance of firefox driver             driver = new firefoxdriver();         }          [teardown]         public void teardown()         {             driver.quit();         }          [test]         public void homepage()         {             //navigate site             driver.navigate().gotourl("http://www.milkround.com");             assert.istrue(iselementpresent(by.id("ctl00_uxtoolbar_uxquerytextboxtoolbar")));          }         catch         {             //verificationerrors.append(e.message);         }          }     } } 

where "iselementpresent" come from? have never seen used in webdriver.

in webdriver need wrap try catch around findelement method.

e.g

boolean elementdisplayed;  try {  webelement element = driver.findelement(by.id("ctl00_uxtoolbar_uxquerytextboxtoolbar")); elementdisplayed = element.displayed;   } catch (nosuchelementexception e) { elementdisplayed = false; } 

obviously can wrap in helper method of kind of perhaps add webdriver classes.

i'll leave you, general idea


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -