Protractor is an extension of selenium, supporting ANGULARJS
Element (By.css (' my-css ')). Click ();
One, using by the various locator positioning elements
Select 1 elements:
Element (By.id (' myID '));
Element (By.css ('. MyClass ')); (Can be abbreviated as: $ (' MyClass '))
Element (By.model (' name ')); Only available for NG
Element (by.binding (' bindingname ')); Only for NG,//Find an element bound to the given variable.
Select multiple elements to return an element collection (array)
var eList = Element.all (By.css ('. MyClass ')); (Can be abbreviated as: $ (' MyClass '))
Elist.count (); Returns 1 Promise, not a simple number
Elist.get (index);
Elist.first ();
Elist.last ();
Multiple selection and operations
Element (By.css (' MyClass ')). All (By.tagname (' tag-within-css '));
Second, to the element action:
!!! All action is asynchronous and the return value is promise!!!!
var ele = Element (by.id (' myID '));
Ele.click ();
Ele.sendkeys (' muy text ');
Ele.clear (); Clear the text
Ele.getattribute (' value '); Get the value of an element
Ele.gettext (). Then (function (text) {//) because the action is asynchronous,
Console.log (text);
You can also write expect here.
}
Three
Appendix: Precautions:
* * Each test case is a new instance, and the browser does not have a cache for the previous test (e.g. search String)
* * If there is more than one action, it is executed sequentially (because it is all asynchronous and will be placed in the event list)
WebApp Automated test tools: Protractor and Selenium