|
Method
|
Example
|
|
get()
|
this.driver.get('http://www.google.com');
|
|
Method
|
Example
|
Purpose
|
|
findElement(by)
|
this.driver.findElement({id: 'MyId'});
|
Finds the first element located by the provided method.
|
|
findElements(by)
|
this.driver.findElements({id: 'MyId'});
|
Finds all elements located by the provided method.
|
|
Method
|
Example
|
Purpose
|
|
window()
|
this.driver.switchTo().window('windowName');
|
moving between named windows
|
|
frame()
|
this.driver.switchTo().frame('frameName');
|
moving between named frames
|
|
Method
|
Example
|
Shorthand
|
|
id()
|
this.driver.findElement(this.driver.By.id('MyId'));
|
this.driver.findElement({id: 'MyId'});
|
|
className()
|
this.driver.findElement(this.driver.By.className('MyClassName'));
|
this.driver.findElement({className: 'MyClassName'});
|
|
tagName()
|
this.driver.findElement(this.driver.By.tagName('img'));
|
this.driver.findElement({tagName: 'img'});
|
|
name()
|
this.driver.findElement(this.driver.By.name('username'));
|
this.driver.findElement({name: 'username'});
|
|
linkText()
|
this.driver.findElement(this.driver.By.linkText('click here!'));
|
this.driver.findElement({linkText: 'click here!'});
|
|
partialLinkText()
|
this.driver.findElement(this.driver.By.partialLinkText('here'));
|
this.driver.findElement({partialLinkText: 'here'});
|
|
css()
|
this.driver.findElement(this.driver.By.css('#food span.dairy.aged'));
|
this.driver.findElement({css: '#food span.dairy.aged'});
|
|
xpath()
|
this.driver.findElement(this.driver.By.xpath('//input'));
|
this.driver.findElement({xpath: '//input'});
|
|
Method
|
Example
|
Purpose
|
|
clear()
|
this.driver.findElement({id: 'submit'}).clear();
|
Clears all of the contents if the element is a text entity.
|
|
click()
|
this.driver.findElement({id: 'submit'}).click();
|
Simulates a mouse click on the element.
|
|
getAttribute()
|
this.driver.findElement({id: 'submit'}).getAttribute('name');
|
Returns the value associated with the provided attribute name (if present) or null (if not present).
|
|
getTagName()
|
this.driver.findElement({id: 'submit'}).getTagName();
|
Returns the tag name for this element.
|
|
getText()
|
this.driver.findElement({id: 'submit'}).getText();
|
Returns the visible text contained within this element (including subelements) if not hidden via CSS.
|
|
getValue()
|
this.driver.findElement({id: 'submit'}).getValue();
|
Gets the value of the element's “value” attribute.
|
|
isEnabled()
|
this.driver.findElement({id: 'submit'}).isEnabled();
|
Returns true for input elements that are currently enabled; otherwise false.
|
|
isSelected()
|
this.driver.findElement({id: 'submit'}).isSelected();
|
Returns true if the element (radio buttons, options within a select, and checkboxes) is currently selected; otherwise false.
|
|
sendKeys(CharSequence… keysToSend)
|
this.driver.findElement({id: 'submit'}).sendKeys(this.webdriver.Key.ENTER);
|
Simulates typing into an element.
|
|
setSelected()
|
this.driver.findElement({id: 'submit'}).setSelected();
|
Select an element (radio buttons, options within a select, and checkboxes).
|
|
submit()
|
{id: 'submit'}).submit();
|
Submits the same block if the element is a form (or contained within a form). Blocks until new page is loaded.
|
|
toggle()
|
this.driver.findElement({id: 'submit'}).toggle();
|
Toggles the state of a checkbox element.
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.