c# - Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index -


i beginner selenium c# .. when trying below code , throwing exception:

index out of range. must non-negative , less size of collection.

parameter name: index

please me on this

class program { static void main(string[] args) {      iwebdriver driver = new chromedriver();     driver.url = @"file:///c:/users/user/documents/visual%20studio%202012/projects/learnselenium_xpath/learnselenium_xpath/testpage.html";     var radiobutton = driver.findelements(by.name("color"))[0]; -->exception     radiobutton.click(); } 

the .findelements not seem find element, causing [0] fail.

you should check result of driver.findelements(by.name("color")) before accessing it.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -