WebApp's Automated testing tools: Protractor and Selenium

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.