[Automation Platform Series]-first use macaca-front end Automation test (2)

Source: Internet
Author: User

Then come down and talk about API usage http://macacajs.github.io/macaca-wd/api/

var _config = {    //host host for this program    : ' http://test.3dker.cn/'}module.exports = _config;

  

var wd = require (' webdriver-client ') ({platformname: ' Desktop ', Browsername: ' Chrome '}), var config = require ('..  /configs.js ');d escribe (' Macaca desktop 3dker article ', function () {this.timeout (5 * 60 * 1000);  Const DRIVER = Wd.initpromisechain ();  Const INITIALURL = config.host + ' article/list ';  Before (() = {return driver. Initdriver (). Setwindowsize (1280, 1200);  });  It (' #0 should go into Macaca ', function () {return driver. Get (Initialurl). Sleep (6000);  }); It (' #1 should works with Macaca ', function () {return driver. Elementbyclassname (' search-article '). SendKeys ( ' AAAA '). Sleep (Elementbyclassname). (' Btn-search '). Click (). Sleep (.) source (). Then      (function (HTML) {//html.should.containeql (' aaaa ');  }). Takescreenshot ();  }); It (' #2 should go into Web ', function () {return driver. Get (Initialurl + '? classify= knowledge sharing #atc-select '). Sleep (  3000);  }); It (' #3 write ArtiCle ', function () {return driver. Elementbyclassname (' Write '). Click (). Sleep (in). elementbyclassn Ame (' username '). SendKeys (' username '). Elementbyclassname (' password '). SendKeys (' pwd '). Elementbyclass       Name (' Do-login '). Click (). Sleep (3000)});  After (done) = {return driver. Quit (done); });});

Get (Initialurl)---You can open a page with chrome,

Elementbyclassname (' search-article ')--received a class named Search-article element

SendKeys (' aaaa ')----Next is the object input box to enter the value we want, or you can use the following method

or Safeeval (' $ (". Search-article"). Val ("56fa2fa3433e3fb103792fcf50806f54")) This is assigned by a script, because the site has a reference to jquery, all support jquery,

Then just go to the departure search press the button, the code is as follows

. Elementbyclassname (' Btn-search ')
. Click ()

The following code, take the class named Smoke-base object, if he contains this class named Smoke-visible, Trigger click event, close the popup layer

. Elementbyclassname (' Smoke-base ')
. Haselementbyclassname (' smoke-visible ')
. Safeeval (' $ (". Dialog-buttons button"). Trigger ("click") ')

[Automation Platform Series]-Initial use of macaca-front end Automation test (2)

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.