以下は、送信ボタンの投稿クリックに失敗した例です。
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", "Shalinitest@test.com");
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();
}
}
注: 以下は、上記の Java スクリプトを実行しようとしたときに発生するエラーです。
com.thoughtworks.selenium.SeleniumException: ERROR: There were no alerts
at com.thoughtworks.selenium.HttpCommandProcessor.
throwAssertionFailureExceptionOrError (HttpCommandProcessor.java:112)