zoukankan      html  css  js  c++  java
  • selenium

    'use strict';

    // 使用包的引入
    const {Builder, By, Key, until,promise} = require('selenium-webdriver');
    const firefox = require('selenium-webdriver/firefox');
    const common = require('./lib/common.js');
    var data = common.getJson('./test2/t.json');

    promise.USE_PROMISE_MANAGER = false;
    //
    var expect = require('chai').expect;

    // 这里可以采用下面的方式来构建(WebDriver)FirefoxDriver实例:(当默认方式打不开浏览器时)
    describe('baidu test Search', function() {
    let profile = new firefox.Profile('C:\Users\****\AppData\Roaming\Mozilla\Firefox\Profiles\s6lckcba.default');
    let options = new firefox.Options().setProfile(profile);
    let driver = new Builder().forBrowser('firefox').setFirefoxOptions(options).build();

    // 分开执行(第一步)
    describe('1', function () {
    before(async function() {
    common.getGolfError(true);
    common.getPhpError(true);
    // let profile = await new firefox.Profile("XXX");

    await driver.get('XXX.html');

    await driver.wait(until.elementLocated(By.id('day')));
    await driver.findElement(By.id('day')).click();//

    await driver.wait(until.elementLocated(By.xpath(data.day)));
    await driver.findElement(By.xpath(data.day)).click();
    // driver.sleep(8);
    await driver.wait(until.elementLocated(By.id(data.area)));
    await driver.findElement(By.id(data.area)).click();
    //await driver.findElement(By.id('search_c_name_submit2')).click();

    });

    beforeEach(async function() {

    });


    afterEach(async function() {
    // await driver.quit();
    });


    after(async function() {
    // await driver.quit();
    });


    // after(async function () {

    // await common.getGolfError(false, function (golf_log_txt) {
    // console.log(golf_log_txt);
    // });

    // await common.getPhpError(false, function (php_log_txt) {
    // console.log(php_log_txt);
    // });
    // // mail
    // await common.getMail(false, function (mail_txt) {
    // console.log(mail_txt);
    // });
    // // await driver.quit();
    // });

    // 校验当前url(当前)
    // it('url test', async function() {
    // let url = await driver.getCurrentUrl();
    // expect(url).to.be.not.equal('www.baidud.com');
    // });
    //校验数值
    it('input test', async function() {
    await driver.wait(until.elementLocated(By.xpath('   ')));
    var day = await driver.findElement(By.xpath('    ')).getAttribute('value');
    expect(day).to.be.equal('   ');
    await console.log(day);
    });
    });

    //

    describe('2', function () {

  • 相关阅读:
    ASP.NET Eval 求值运算的一些用法
    SQLSERVER中统计所有表的记录数
    一份很全的路由器默认初始密码集合
    将DataTable导出为excel
    如何强制修改mysql的root密码(mysql忘记密码)
    資料庫的安全(備份/回存)(console)
    ffserver和ffmpeg配合完成的实时流媒体服务
    mssql里sp_MSforeachtable和sp_MSforeachdb的用法
    ASP.NET中GridView中嵌套GridView
    How to update multiple columns of one table using values from another table?
  • 原文地址:https://www.cnblogs.com/luxia/p/10117971.html
Copyright © 2011-2022 走看看