随笔分类 - selenium webdriver(Java)
摘要:import org.openqa.selenium.WebDriver;import org.openqa.selenium.ie.InternetExplorerDriver;import org.openqa.selenium.remote.DesiredCapabilities;import...
阅读全文
摘要:public class Table { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub WebD...
阅读全文
摘要://山寨法 String setscroll = "document.documentElement.scrollTop=100"; JavascriptExecutor jse=(JavascriptExe...
阅读全文
摘要:public static void main(String[] args) { //TestUtils.killProcess("javaw.exe"); TestUtils.killProcess("iexplore.exe"); WebDriver driver=ExplorerBase.IESetting(); driver.manage().window().maximize(); String baseUrl= "http://www.baidu.com/"; ...
阅读全文
摘要:getText(),获得标签内文本getAttribute("title")获得对应的html属性值
阅读全文
摘要:ITeye:http://shijincheng0223.iteye.com/blog/1481446 http://ztreeapi.iteye.com/blog/1750554http://smilejay.com/2012/09/selenium-webdriver-with-ie/http://uniquepig.iteye.com/blog/1703553http://wenku.baidu.com/view/a5d218cdb14e852458fb571c.html?pn=51
阅读全文
摘要:/**显示等待并返回元素 * @param driver * @param locator */ public static WebElement showWait(WebDriver driver, final String locator) { return new WebDriverWait(driver, 10).until(new ExpectedCondition() { public WebElement apply(WebDriver ...
阅读全文
摘要:@Test public void testRadio() { WebDriver driver = ExplorerBase.IESetting(); try { Thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } driver.manage().window().maxim...
阅读全文
摘要:@Test public void test() { WebDriver driver=ExplorerBase.IESetting(); driver.get("http://uniquepig.iteye.com/signup"); driver.manage().window().maximize(); //在读学生 Select select = new Select(driver.findElement(By.id("user_gender"))); select.selectByVisible...
阅读全文
摘要:/**截图 * @param driver * @param name */ public static void takeScreenShot(WebDriver driver,String name){ File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); try { FileUtils.copyFile(scrFile, new File("c:\\"...
阅读全文
摘要:public class BaiduTest { private WebDriver driver; private String baseUrl; private StringBuffer verificationErrors = new StringBuffer(); @Before public void setUp() throws Exception { driver = ExplorerBase.IESetting(); baseUrl = "http://www.baidu.com/"; driver.manage().timeouts().impli...
阅读全文
摘要:@Test public void testElementByID() { //通过JS获取页面元素 driver.get(url); driver.manage().window().maximize(); try { Thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); ...
阅读全文
摘要:static final WebDriver driver = ExplorerBase.IESetting(); // 实例化一个浏览器对象 @Test //@Ignore public void findBaiDuElements() { try { Thread.sleep(500); } catch (InterruptedException e1) { e1.printStackTrace(); } driver.manage().window().maxim...
阅读全文
摘要:/**模拟鼠标悬浮在某元素上 * @param driver * @param locator */ public static void moveToElement(WebDriver driver, By locator) { Actions ...
阅读全文
摘要:/** * 判断元素是否存在 * * @param driver * @param by * @return */ public static boolean isElementPresent(WebDriver driver, By by) { try { driver.findElement(by); return true; } catch (NoSuchElementException e) { return false; ...
阅读全文
摘要:public static FirefoxDriver FFSetting() { System.setProperty("webdriver.firefox.bin", "D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); return new FirefoxDriver(); } public static InternetExplorerDriver IESetting() { System.setProperty("webdriver...
阅读全文
摘要:selenium webdriver在IE下执行View Code public static void main(String[] args) { //webdriver执行IE,IE保护模式全部启用、保护模式全部不启用 System.setProperty("webdriver.ie.driver","D:\\selenium\\IEDriverServer.exe"); DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer(); ...
阅读全文

浙公网安备 33010602011771号