Selenium commonly used commands

1、open

  Open (URL)
  - Open the URL in the browser can accept two forms of relative and absolute path
2, type
  type (inputLocator, value)
  , specified in input to the input value of the analog input manual process -
  - but also to check for and radio buttons assignment 
3, the click
  the click (elementLocator)
  - click connection buttons, radio buttons and check
  - If clicking the need to wait for a response, then use the "clickAndWait"
  - if it is to go through a JavaScript alert or confirm box after in order to proceed, you need to call to verify or assert Selenium tell you what action is expected of the dialog box. 
4, goBack ()
  Analog click your browser's back button
5, close ()

 Click the Close button analog browser

6、select

  select(dropDownLocator, optionSpecifier)

  - The optionSpecifier option selector selects a drop-down menu option - if more than one selector, when used as a wildcard mode, such as "f * b *", or more than one option with the same text or value, then select first matching value

7, the positioning element and an operation id name class name link text partial link text tag name css selector xpath

7.1, by the positioning element's ID: findElement (By.id ( "ele" ));

7.2, by the positioning element's names: findElement (By.name ( "ele"));

7.3, the position of the html element targeting elements: findElement (By.xpath ( "ele"));

7.4, the positioning element by element tag name: findElement (By.tagName ( "ele"));

7.5, by linking the positioning element's name: findElement (By.LinkText ( "ele"));

7.6, by the positioning element's class name: findElement (By.className ( "ele"));

7.7, css positioning element by element: findElement (By.cssSelector ( "ele");

7.8, part of the link name positioning element by element: findElement (By.pareialLinkText ( "ele"));

8, to perform a click operation ID of an element ele: driver.findElement (By.id (ele));

9, the operation of the character ID is transmitted to the element ele: driver.findElement (By.id (ele) .sendKeys ( "123456"));

10, operation of and access to page elements Click: element.click ()

11, filled out: element.SendKeys ()

12. Empty: element.clear ()

13, submit: element.submit ()

14, to obtain the title: driver.getTitle ()

15, get Url: driver.getCurrentUrl ()

16, gets the text: driver.getText ()

17, the case memory check: element.isSelected ()

18, to verify whether the element can be displayed: element.isDisplayed ()

19, to obtain a label name: element.getTagName ()

20, to obtain the value of the specified property: element.getAttribute ()

21, the storage editable state: element.isEnabled ()

22, operation of the browser open the page: driver.navigate () to ( "");.

23, the browser is maximized: driver.manage () window () maximize ()..

24, forward, backward: navigation.back () navigation.forward ()

25, refresh: navigation.refresh ()

26, for the ordinary keyboard, to use sendKeys (keysToSend) can be achieved, for example key TAB, Backspace, etc.

  Actions action = new Actions(driver);

  action.sendKeys(Keys.TAB);

  // simulate press and release the TAB key

  action.sendKeys(Keys.SPACE);

  // analog Press and release the Spacebar / *** issued a keyboard key operation for a certain element, or input operations, such as in the input box, enter a character can also use this method. This method can also be split into: action.click (element) .sendKeys (keysToSend). action.sendKeys (element, keysToSend);

27, left-click:

  Actions action = new Actions(driver);

  action.click(driver.findElement(By.name(element)))

28, right-click on:

  Actions action = new Actions(driver);

  action.contextClick(driver.findElement(By.name(element)))

29, double-click:

  Actions action = new Actions(driver);

  action.doubleClick(driver.findElement(By.name(element)));

30, where it just want to traverse the drop-down list of all the options, the options were selected by click           

  Select selectCity = new  Select(dr.findElement(By.id("User_City")));    
  for(WebElement e : selectCity.getOptions())                

  e.click();   

31, select the "Shanghai" This is an attribute value by drop-down list of options          

  Select selectShen = new 
    Select(dr.findElement(By.id("User_Shen")));          

       selectShen.selectByValue("上海");

32, the second item is selected by the index drop-down list of options

  Select selectAge = new 
    Select(dr.findElement(By.id("User_Age")));      

    selectAge.selectByIndex(2);

Guess you like

Origin www.cnblogs.com/miaosj/p/11976692.html