Search code examples
c#selenium-webdriverautomated-tests

Can not input desired number using selenium


I am doing task using selenium in C# (NUnit). in my task I have to perform some tasks in "Google Cloud Pricing Calculator" (I have to input 4 in "number of instances field", select N1 series, etc.)

I have tried to find element by its ID but selenium could not find it. Then I tried "thread.sleep();" function but it did not work either. After that I tried to use "WebDriverWait" and it did not work either.

iframe and previous elements

this is "Number of instances" field, where i tried to find element by ID and css selector


Solution

  • On this website you have nested iframes. You'll need to step into the first Iframe, and then into the second.

    driver.SwitchTo().Frame(By.XPath("//devsite-iframe/iframe"));
    driver.SwitchTo().Frame(By.XPath("//iframe[@id='myFrame']"));
    // Your code here
    driver.SwitchTo().DefaultContent();
    

    This will step into the iframes that hold the number of instances, then step all the way back out.