Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Below is the example where i failed post clicking of submit button:

package demo;

import static org.junit.Assert.assertEquals;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

public class leadtest 
        {
    private Selenium selenium;
    private SeleniumServer server;

    @Before
    public void setUp() throws Exception 
                {
        server = new SeleniumServer();
        server.start();
        selenium = new DefaultSelenium("localhost", 4444, "*firefox",
            "http://www.careerfundas.com/");
        selenium.start();
            }

    @Test
   public void testLeadtest() throws Exception
                {
        selenium.open("/");
        selenium.click("id=wrapper");
        selenium.click("css=a.active-home > span");
        selenium.waitForPageToLoad("30000");
        selenium.click("id=wrapper");
        selenium.click("css=li");
        selenium.waitForPageToLoad("30000");
        selenium.click("id=confused_name");
        selenium.type("id=confused_name", "Shalini test");
        selenium.type("id=confused_email", "[email protected]");
        selenium.type("id=confused_phoneno", "9090909090");
        selenium.select("id=conf_course", "label=Shipping and Logistics");
        selenium.click("link=Ask Expert");
        assertEquals(
            "Thank You ! Someone from Career Fundas experts panel will    contact you shortly.", selenium.getAlert());


            }



    @After
    public void tearDown() throws Exception 
       {
        selenium.stop();
   }

      }  

Note: Below is the error i am getting when i tried to run above java script.

com.thoughtworks.selenium.SeleniumException: ERROR: There were no alerts
at com.thoughtworks.selenium.HttpCommandProcessor.
throwAssertionFailureExceptionOrError (HttpCommandProcessor.java:112)
share|improve this question
May be, the alert is not displayed by the time server is executing getAlert() command. Try adding selenium.waitforpagetoload(30000); before assertion statement and check the behaviour. If still you are facing issue. let us know. – HemChe Mar 28 at 5:35

2 Answers

  1. You may try setting the speed by selenium.setSpeed("5000") before you do a geralert.

  2. Maybe it is not alert. Maybe it is confirmation. Did you try selenium.getConfirmation();

Here is some More information on it.

share|improve this answer
selenium.click("link=Ask Expert");
Thread.sleep(5000);
assertEquals("Thank You ! Someone from Career Fundas experts panel will contact you shortly.", selenium.getAlert());

Use this code, its working at my end

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.