selenium - WebDriver and C# - NoSuchElement exception -


i have following code selecting option given list , works, fails nosuchelement exception on second if. under impression if not find element goes through loop again. believe explanation pretty simple... enlighten me?

    public static void selectfromlist(string vlist, string vtext, iwebdriver driver)     {         (int sec = 0; ; sec++)         {             system.threading.thread.sleep(2500);             if (sec >= 10) debug.fail("timeout : " + vlist);             if (driver.findelement(by.id(configurationmanager.appsettings[vlist])).displayed) break;         }         new selectelement(driver.findelement(by.id(configurationmanager.appsettings[vlist]))).selectbytext(vtext);     } 

well, java guy, not provide code, rather algorithm:

  • yours code (i think) should check, if element displayed , if not, wait 2,5 secs
  • the reason fails is, takes more first 2,5 secs display element. in case, check if element displayed throw exception

so, should exception handling in loop , catch exception , nothing. in java done try , catch block. because dont know c# have find out how done in language


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -