import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
public class RedBus {
Selenium selenium;
@BeforeClass
public void base()
{
Selenium selenium = new DefaultSelenium("localhost",4444,"*firefox","http://www.redbus.in");
selenium.start();
selenium.windowMaximize();
selenium.open("/");
selenium.waitForPageToLoad("10000");
}
@Test
public void domain() throws InterruptedException
{
selenium.type("//input[@id='DDLSource']","hyde");
Thread.sleep(5000);
selenium.waitForPageToLoad("10000");
if(selenium.isTextPresent("//dt[@value='Hyderabad']"))
{
selenium.click("//dt[@value='Hyderabad']");
}
else{
System.out.println("ele not found");
}
/*
selenium.type("//input[@id='DDLDestination']","pune");
selenium.click("//img[@alt='Select your date of journey']");
*/
}
}
1045 次
3 に答える
0
これを試して
DefaultSelenium selenium=null;
// Selenium selenium の代わりにこれを使用します。
WebDriver ドライバー = 新しい FirefoxDriver(); selenium = new WebDriverBackedSelenium(driver, " http://www.redbus.in ");
// selenium.start(); を使用する必要はありません。またはデフォルトのポートを設定します
// 次の行
selenium.type
.. は、Firefox 35 以降を使用している場合でも null ポインターを返します。最初に試してfirefox 15
からチェックしfirefox 34
てください。34をインストールした後は、Firefoxの更新を行わないでください。
私は次の瓶を使用しました
selenium-server-coreless-1.0-20081010.060147.jar selenium-java-2.44.0.jar selenium-server-standalone-2.44.0.jar
//インポート文
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;
よろしく、 Ravinath Edirisinghe
于 2015-02-18T05:56:03.473 に答える