Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
basic.execute(driver, 'sendKeys', 'h4[about="v-fs:EnterQuery"]+div[class="form-group"] input', "Cannot find input field", timeStamp);
// Нажимаем поиск и удостоверяемся что в результатах поиска появился созданный выше документ
driver.wait
(
function () {
basic.execute(driver, 'click', 'h4[about="v-fs:EnterQuery"]+div[class="form-group"] button[id="submit"]', "Cannot click on submit button");
driver.sleep(basic.FAST_OPERATION); // Иначе слишком часто щелкает поиск
return driver.findElement({css:'span[href="#params-ft"]+span[class="badge"]'}).getText().then(function (txt) {
return txt == '1';
});
},
basic.EXTRA_SLOW_OPERATION
).thenCatch(function (e) {basic.errorHandler(e, "Cannot find person, after save operation");});
driver.wait
(
webdriver.until.elementTextContains(driver.findElement({css:'div[id="search-results"] span[property="v-s:middleName"]'}),timeStamp),
basic.FAST_OPERATION
).thenCatch(function (e) {basic.errorHandler(e, "Found person differs from saved person");});
console.timeEnd("testPerson");
driver.quit();
});
'use strict'
/* eslint-env mocha */
// The geckodriver package downloads and installs geckodriver for us.
// We use it by requiring it.
require('geckodriver')
let firefox = require('selenium-webdriver/firefox')
let webdriver = require('selenium-webdriver')
let FxRunnerUtils = require('fx-runner/lib/utils')
let Fs = require('fs-promise')
let By = webdriver.By
let Context = firefox.Context
let until = webdriver.until
let path = require('path')
// Note: Geckodriver already has quite a good set of default preferences
// for disabling various items.
// https://github.com/mozilla/geckodriver/blob/master/src/marionette.rs
const FIREFOX_PREFERENCES = {
// Ensure e10s is turned on.
'browser.tabs.remote.autostart': true,
'browser.tabs.remote.autostart.1': true,
'browser.tabs.remote.autostart.2': true,
// These are good to have set up if you're debugging tests with the browser
// toolbox.
'devtools.chrome.enabled': true,
'devtools.debugger.remote-enabled': true
}
openCreateDocumentForm: function (driver, templateName, templateRdfType, phase) {
// Клик `Документ` в главном меню
driver.findElement({id:'menu'}).click()
.thenCatch(function (e) {errrorHandlerFunction(e, "****** PHASE#" + phase + " : ERROR = Cannot click on settings button")});
// Проверяем что открылось подменю
driver.wait
(
webdriver.until.elementIsVisible(driver.findElement({css:'li[id="menu"] li[resource="v-l:Create"]'})),
FAST_OPERATION
).thenCatch(function (e) {errrorHandlerFunction(e, "****** PHASE#" + phase + " : ERROR = Seems there is no `create` button inside menu")});
// Клик `Создать`
driver.findElement({css:'li[id="menu"] li[resource="v-l:Create"]'}).click()
.thenCatch(function (e) {errrorHandlerFunction(e, "****** PHASE#" + phase + " : ERROR = Cannot click on `create` button")});
// Проверяем что открылась страница создания документов
driver.wait
(
webdriver.until.elementIsVisible(driver.findElement({css:'div[resource="v-fc:Create"]'})),
FAST_OPERATION
).thenCatch(function (e) {errrorHandlerFunction(e, "****** PHASE#" + phase + " : ERROR = Create template was not opened")});
// Вводим запрашиваемый тип документа
driver.findElement({css:'input.fulltext.tt-input'}).clear();
/* global promise, run */
var webdriver = require('selenium-webdriver');
var Hook = require('mocha').Hook;
var stackTrace = require('stack-trace');
var LogManager = require('./logManager');
var Helper = require('./helper');
//simplify webdriver usage
global.by = webdriver.By;
global.key = webdriver.Key;
global.promise = webdriver.promise;
global.bot = webdriver.error;
global.until = webdriver.until;
module.exports = fiveby;
function fiveby(config) {
this.config = config;
this.logManager = new LogManager();
this.file = stackTrace.get()[2].getFileName();
}
//spin up local selenium server if none provided
fiveby.prototype.localServer = function () {
if (global.serverPromise) {
return global.serverPromise;
} else if (!global.fivebyConfig.hubUrl && !this.config.hubUrl) {
var helper = new Helper();
global.serverPromise = helper.isJava()
this.Given(/^Login Succeeds$/, function () {
var condition = seleniumWebdriver.until.elementLocated({name: 'allow'});
return this.driver.wait(condition, 10000);
});
describe("Selenium tests for the html-page", function () {
const webdriver = require('selenium-webdriver'),
chrome = require('selenium-webdriver/chrome'),
By = webdriver.By,
until = webdriver.until,
Key = webdriver.Key
const opts = new chrome.Options()
opts.addArguments('headless')
const driver = new webdriver.Builder()
.setChromeOptions(opts)
.forBrowser('chrome')
.build();
this.timeout(10000)
it('should use the actual html-page and verify the last word', async () => {
const workingDir = process.cwd()
const fileUrl = "file://" + workingDir + "/calculator/last-word.html"
await driver.get(fileUrl);
await driver.findElement(By.id('seedphrase_ta'))
function evalPyret(driver, toEval) {
var replOutput = driver.findElement(webdriver.By.id("output"));
var breakButton = driver.findElement(webdriver.By.id('breakButton'));
var livePrompt = driver.findElement(webdriver.By.className('prompt-container'));
var escaped = escape(toEval);
driver.executeScript([
"(function(cm){",
"cm.setValue(unescape(\"" + escaped + "\"));",
"cm.options.extraKeys.Enter(cm);",
"})",
"($(\".repl-prompt > .CodeMirror\")[0].CodeMirror)"
].join(""));
driver.wait(webdriver.until.elementIsVisible(livePrompt));
return replOutput.findElements(webdriver.By.xpath("*")).then(function(elements) {
if (elements.length === 0) {
throw new Error("Failed to run Pyret code, no elements after executing: " + toEval);
} else {
return elements[elements.length - 1];
}
});
}
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var port = process.env.PORT;
var driver;
var errors;
function start(caps) {
if (driver) throw Error('Previous session not stopped.');
var driverFu;
if (process.env.SAUCE_USERNAME) {
var tunnelId, buildId;
if (process.env.TRAVIS === 'true') {
tunnelId = process.env.TRAVIS_JOB_NUMBER;
buildId = process.env.TRAVIS_BUILD_NUMBER;
}
else if (process.env.SAUCE_TUNNEL_ID) {
$browser.waitForElement = function (locatorOrElement, timeoutMsOpt) {
return $browser.wait($driver.until.elementLocated(locatorOrElement), timeoutMsOpt || 5000, 'Timed-out waiting for element to be located using: ' + locatorOrElement);
};