ios自动化测试safri脚本

作者:admin / 时间:10个月前 (02/25) / 分类:后端测试 / 阅读:1900 / 评论:0

"use strict";

require("./helpers/setup");

var wd = require("wd"),

    _ = require('underscore'),

    serverConfigs = require('./helpers/appium-servers');

describe("ios safari", function () {

  this.timeout(300000);

  var driver;

  var allPassed = true;


  before(function () {

    var serverConfig = serverConfigs.local;

    driver = wd.promiseChainRemote(serverConfig);

    require("./helpers/logging").configure(driver);

    var desired = _.clone(require("./helpers/caps").ios81);

    desired.browserName = 'safari';

    return driver.init(desired);

  });

  after(function () {

    return driver.quit()

  });

  afterEach(function () {

    allPassed = allPassed && this.currentTest.state === 'passed';

  });

  it("should get the url", function () {

    return driver

      .get('https://www.google.com')

      .sleep(1000)

      .waitForElementByName('q', 5000)

        .sendKeys('sauce labs')

        .sendKeys(wd.SPECIAL_KEYS.Return)

      .sleep(1000)

      .title().should.eventually.include('sauce labs');

  });

  it("should delete cookie passing domain and path", function () {

    var complexCookieDelete = function(name, path, domain) {

      return function() {

        path = path || '|';

        return driver.setCookie({name: name, value: '', path: path, 

          domain: domain, expiry: 0});        

      };

    };

    return driver

      .get('http://en.wikipedia.org')

      .waitForElementByCss('.mediawiki', 5000)

      .allCookies() // 'GeoIP' cookie is there

      .deleteCookie('GeoIP') 

      .allCookies() // 'GeoIP' is still there, because it is set on

                    // the .wikipedia.org domain

      .then(complexCookieDelete('GeoIP', '/', '.wikipedia.org'))

      .allCookies() // now 'GeoIP' cookie is gone

      .sleep(1000);

  });

});


没有评论,留下你的印记,证明你来过。


发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。