Selenium webdriver doesn't click on save button in chrome and firefox

My project is in mvc and I want to test it using selenium web driver. Some button clicks work properly. But when I navigate to different page saying continue on that page Save button doesn't work.

Below is my code

        driver.FindElement(By.Id("BtnAddNew")).Click();

        IWebElement cat = driver.FindElement(By.Id("Cat"));
        cat.SendKeys("Single-family house");

        IWebElement ext_id = driver.FindElement(By.Id("ExternalId"));
        ext_id.SendKeys("SAR_47");

        IWebElement zip = driver.FindElement(By.Id("AddressZipTown"));
        zip.SendKeys("1205 Genève");

        IWebElement street = driver.FindElement(By.Id("AddressStreet"));
        street.SendKeys("Tramstrasse 10");

        driver.FindElement(By.Id("btnContinue")).Click();

        driver.FindElement(By.Id("btnSave")).Click();

        driver.Quit();

Can anyone solve my problem?

Answers


You can solve this problem by checking the DOM for a certain amount of time to try to find your WebElement. You can use Implicit or Explicit Waits.

Doc:

http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp#explicit-waits http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp#implicit-waits


Need Your Help

How to create a vector of integers with structure()?

r types integer

I don't seem to be able to produce a vector of integers using structure().

Does C# have a String Tokenizer like Java's?

c# string parsing

I'm doing simple string input parsing and I am in need of a string tokenizer. I am new to C# but have programmed Java, and it seems natural that C# should have a string tokenizer. Does it? Where is...