1

I was trying to write a C# & Selenium automation code to visit a webpage and click some elements to arrive at another webpage. So in the process, I am supposed to click a checkbox which is present inside a table , which in turn is present inside an Iframe. I have checked the page source, and have confirmed that there exists only 1 Iframe.

I tried running the following code and get the following error:

no such element: Unable to locate element

this is a snippet of the code I've used-

 webDriver.SwitchTo().DefaultContent();
            wait.Until(ExpectedConditions.ElementIsVisible(By.TagName("iframe")));
            webDriver.SwitchTo().Frame(webDriver.FindElement(By.TagName("iframe")));
            System.Threading.Thread.Sleep(5000);
           // webDriver.SwitchTo().DefaultContent();
            wait.Until(ExpectedConditions.ElementToBeClickable(webDriver.FindElement(By.CssSelector("#AjaxTable78962_t1 > tbody > tr:nth-child(5) > td:nth-child(1) > input[type=\"checkbox\"]"))));

I get the exception on this line:

wait.Until(ExpectedConditions.ElementToBeClickable(webDriver.FindElement(By.CssSelector("#AjaxTable78782_t1 > tbody > tr:nth-child(5) > td:nth-child(1) > input[type=\"checkbox\"]"))));
  • That table ID (AjaxTable78782_t1) looks like it might be dynamically generated? – ernie Oct 27 '17 at 17:10
  • yes it is dynamically generated , I recently noticed that . – That-Kickass-GirL Oct 31 '17 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.