c# - Unable to locate element and the 'By' class while using Selenium with NUnit -
i trying run selenium ide generated script nunit using visual studio. encountering error:
cannot open file: 'c:\projects\webdriver\dotnet\src\webdriver\remote\remotewebdriver.cs' error- 'file not exist.
file- c:\projects\webdriver\dotnet\src\webdriver\remote\remotewebdriver.cs'
and
cannot open file: 'c:\projects\webdriver\dotnet\src\webdriver\by.cs'
error- 'file not exist. file- c:\projects\webdriver\dotnet\src\webdriver\by.cs'
i tried xpath instead of name/id, error still persisted. don't have idea why looking these files there when have neither nunit nor selenium directory there.
code:
[test] public void theforseleniumassignmenttest() { string baseurl = "http://www.cakespot.in"; iwebdriver driver = new firefoxdriver(); driver.navigate().gotourl(baseurl + "/"); thread.sleep(8000); driver.findelement(by.xpath("(//a[contains(text(),'more pictures')])[2]")).click(); thread.sleep(8000); driver.findelement(by.name("name")).sendkeys("pooja"); driver.findelement(by.id("phone")).clear(); driver.findelement(by.id("phone")).sendkeys("123456"); new selectelement(driver.findelement(by.id("date"))).selectbytext("14"); new selectelement(driver.findelement(by.id("month"))).selectbytext("5"); new selectelement(driver.findelement(by.id("time"))).selectbytext("8:30"); new selectelement(driver.findelement(by.id("day"))).selectbytext("pm"); driver.findelement(by.id("button")).click(); }
for by.cs file issue go page, there you'll find by.cs file save cs file using notepad or similar software(make sure it's .cs file , not .txt).
now when same issue should find browse file link in window when error occurs. browse saved file (by way if can't find via visual studio means didn't save .cs file).
alternatively download whole .zip file , browse wanted .cs file.
well it's looking file because tried step line cause exception.
Comments
Post a Comment