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)