我是一名java程序员,我是新手使用selenium库,我想熟悉它。我在Google搜索了大量页面,但无法找到正确的地方来学习基本的selenium编程。请建议我一个很好的链接,通过基本程序为硒初学者。
我的期望是打开并执行某些操作,例如单击按钮,向下拖动滚动条,下拉列表等。
答案 0 :(得分:1)
答案 1 :(得分:0)
package nandu;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class Webpack {
WebDriver d;
@Test
public void testAjax() throws Exception
{
d.manage().timeouts().implicitlyWait(3,TimeUnit.MINUTES);
d.manage().window().maximize();
d.get("http://www.veethi.com/places/india_banks-ifsc-micr-codes.html");
Select bank=new Select(d.findElement(By.id("selBank")));
bank.selectByIndex(4);
Select state=new Select(d.findElement(By.id("selState")));
state.selectByVisibleText("Andhra Pradesh");
Select city=new Select(d.findElement(By.id("selCity")));
city.selectByVisibleText("Hyderabad");
Select branch=new Select(d.findElement(By.id("selBranch")));
branch.selectByVisibleText("Banjara Hills");
Thread.sleep(5000);
}
@BeforeMethod
public void initilaization() throws Exception
{
d=new FirefoxDriver();
}
@AfterMethod
public void teardown()
{
d.quit();
}
}