Thanks to visit codestin.com
Credit goes to github.com

Skip to content

peacehep/SeleniumDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Selenium WebDriver API 的基础用法

均整理自网络,仅供学习参考

Default Path

Specified Path

close() or quit()

maximize()

SetSize()

get()

navigate().to() and navigate().to().back()/forward()

Locate one object

Locate multiple objects

sendKeys()

clear()

click()

Locate father div tag and then to locate all the following objects

Hiberarchy

Alert Class

Alert, Confirm and Prompt

switchTo().alert()

getText()

accept() and dismiss()

switchTo().frame()

switchTo().defaultContent()

Class:Select

select.selectByIndex("index");

select.selectByValue("value");

domain,name,value,expriy,path

driver.manage().addCookie();

driver.manage().getCookie();

dr.manage().deleteCookieNamed("Cookies Name");

dr.manage().deleteCookie("CookieName");

dr.manage().deleteAllCookies();

  • Take Screenshot

     import org.openqa.selenium.TakesScreenshot;
     File screenshotFile = ((TakesScreenshot)dr).getScreenshotAs(OutputType.FILE);
    
  • Firefox Profile

add new profile

use existing profile

temporary sepecified plug-in

enable function

firefox proxy setting

getAttribute(); getText(); getCssValue();

isDisplayed(); isSelected(); isEnabled();

  • Execute JavaScript

     JavascriptExecutor)dr).executeScript("alert(\"hello,this is a alert!\")");
     ((JavascriptExecutor)dr).executeScript("$(arguments[0]).fadeOut();", button);
    
  • Drag and Drop

     (new Actions(dr)).dragAndDrop(from,to).perform();
    

Other operations in Action Class (KeyDown, KeyUp, Click,sendKeys,doubleClick,clickAndHold, release,moveToElement, contextClick)

File Class

sendKeys

setPreference

explicit wait

		explicit_wait.until(new ExpectedCondition<WebElement>(){
		
		@Override
		public WebElement apply(WebDriver d){
			
			return d.findElement(By.id("b"));
		}
		}).click();

implicit wait

	dr.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);

About

Selenium WebDriver Demo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages