forked from enviPath/enviPy
Current Dev State
This commit is contained in:
43
static/js/ketcher2/node_modules/webdriverio/lib/commands/$$.js
generated
vendored
Normal file
43
static/js/ketcher2/node_modules/webdriverio/lib/commands/$$.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* The `$$` command is a short way to call the [`elements`](/api/protocol/elements.html) command in order
|
||||
* to fetch multiple elements on the page. It returns an array with element results that will have an
|
||||
* extended prototype to call action commands without passing in a selector. However if you still pass
|
||||
* in a selector it will look for that element first and call the action on that element.
|
||||
*
|
||||
* You can chain `$` or `$$` together in order to walk down the DOM tree.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<ul id="menu">
|
||||
<li><a href="/">Home</a></li>
|
||||
<li><a href="/">Developer Guide</a></li>
|
||||
<li><a href="/">API</a></li>
|
||||
<li><a href="/">Contribute</a></li>
|
||||
</ul>
|
||||
|
||||
:$.js
|
||||
it('should get text a menu link', function () {
|
||||
var text = $('#menu');
|
||||
|
||||
console.log(text.$$('li')[2].$('a').getText()); // outputs: "API"
|
||||
// same as
|
||||
console.log(text.$$('li')[2].getText('a'));
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias $$
|
||||
* @param {String} selector selector to fetch multiple elements
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
let $$ = function (selector) {
|
||||
return this.elements(selector).then((res) => res.value.map((el, i) => {
|
||||
el.value = { ELEMENT: el.ELEMENT }
|
||||
el.selector = selector
|
||||
el.index = i
|
||||
return el
|
||||
}))
|
||||
}
|
||||
|
||||
export default $$
|
||||
38
static/js/ketcher2/node_modules/webdriverio/lib/commands/$.js
generated
vendored
Normal file
38
static/js/ketcher2/node_modules/webdriverio/lib/commands/$.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* The `$` command is a short way to call the [`element`](/api/protocol/element.html) command in order
|
||||
* to fetch a single element on the page. It returns an object that with an extended prototype to call
|
||||
* action commands without passing in a selector. However if you still pass in a selector it will look
|
||||
* for that element first an call the action on that element.
|
||||
*
|
||||
* You can chain `$` or `$$` together in order to walk down the DOM tree.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<ul id="menu">
|
||||
<li><a href="/">Home</a></li>
|
||||
<li><a href="/">Developer Guide</a></li>
|
||||
<li><a href="/">API</a></li>
|
||||
<li><a href="/">Contribute</a></li>
|
||||
</ul>
|
||||
|
||||
:$.js
|
||||
it('should get text a menu link', function () {
|
||||
var text = $('#menu');
|
||||
|
||||
console.log(text.$$('li')[2].$('a').getText()); // outputs: "API"
|
||||
// same as
|
||||
console.log(text.$$('li')[2].getText('a'));
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias $
|
||||
* @param {String} selector selector to fetch a certain element
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
let $ = function (selector) {
|
||||
return this.element(selector)
|
||||
}
|
||||
|
||||
export default $
|
||||
47
static/js/ketcher2/node_modules/webdriverio/lib/commands/addCommand.js
generated
vendored
Normal file
47
static/js/ketcher2/node_modules/webdriverio/lib/commands/addCommand.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
*
|
||||
* Add custom command to client/browser instance. Read more about `addCommand` [here](/guide/usage/customcommands.html).
|
||||
*
|
||||
* <example>
|
||||
:addCommandAsync.js
|
||||
// adding `async` as function name disables the synchronous behavior of WebdriverIO commands
|
||||
// in case you need to interact with other 3rd party libraries that support promises
|
||||
client.addCommand("getUrlAndTitle", function async (customVar) {
|
||||
return this.url().then(function(urlResult) {
|
||||
return this.getTitle().then(function(titleResult) {
|
||||
console.log(customVar); // "a custom variable"
|
||||
return { url: urlResult.value, title: titleResult }
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
:addCommand.js
|
||||
browser.addCommand("getUrlAndTitle", function (customVar) {
|
||||
return {
|
||||
url: this.getUrl(),
|
||||
title: this.getTitle(),
|
||||
customVar: customVar
|
||||
}
|
||||
})
|
||||
|
||||
:example.js
|
||||
it('should use my custom command', function () {
|
||||
browser.url('http://www.github.com')
|
||||
var result = browser.getUrlAndTitle('foobar')
|
||||
|
||||
assert.strictEqual(result.url, 'https://github.com/')
|
||||
assert.strictEqual(result.title, 'GitHub · Where software is built')
|
||||
assert.strictEqual(result.customVar, 'foobar')
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.addCommand
|
||||
* @param {String} commandName name of your custom command
|
||||
* @param {Function} customMethod your custom method
|
||||
* @param {Boolean} overwrite if set to `true` you can overwrite existing commands
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
// Nothing to see here!
|
||||
// You can find the actual implementation in /lib/webdriverio.js
|
||||
66
static/js/ketcher2/node_modules/webdriverio/lib/commands/addValue.js
generated
vendored
Normal file
66
static/js/ketcher2/node_modules/webdriverio/lib/commands/addValue.js
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
*
|
||||
* Add a value to an object found by given selector. You can also use unicode
|
||||
* characters like Left arrow or Back space. WebdriverIO will take care of
|
||||
* translating them into unicode characters. You’ll find all supported characters
|
||||
* [here](https://w3c.github.io/webdriver/webdriver-spec.html#dfn-character-types).
|
||||
* To do that, the value has to correspond to a key from the table.
|
||||
*
|
||||
* <example>
|
||||
:addValue.js
|
||||
it('should demonstrate the addValue command', function () {
|
||||
var input = $('.input')
|
||||
input.setValue('test')
|
||||
input.addValue(123)
|
||||
|
||||
// same as
|
||||
browser.setValue('.input', 'test')
|
||||
browser.addValue('.input', '123')
|
||||
|
||||
var value = elem.getValue()
|
||||
assert(value === 'test123') // true
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.addValue
|
||||
* @param {String} selector Input element
|
||||
* @param {String|Number} values value to be added
|
||||
* @uses protocol/elements, protocol/elementIdValue
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let addValue = function (selector, value) {
|
||||
/*!
|
||||
* parameter check
|
||||
*/
|
||||
if (typeof value === 'number') {
|
||||
value = '' + value
|
||||
}
|
||||
|
||||
if (typeof value !== 'string' && !Array.isArray(value)) {
|
||||
throw new CommandError('number or type of arguments don\'t agree with addValue command')
|
||||
}
|
||||
|
||||
return this.elements(selector).then((res) => {
|
||||
if (!res.value || res.value.length === 0) {
|
||||
/*!
|
||||
* throw NoSuchElement error if no element was found
|
||||
*/
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
let self = this
|
||||
let elementIdValueCommands = []
|
||||
|
||||
for (let elem of res.value) {
|
||||
elementIdValueCommands.push(self.elementIdValue(elem.ELEMENT, value))
|
||||
}
|
||||
|
||||
return this.unify(elementIdValueCommands)
|
||||
})
|
||||
}
|
||||
|
||||
export default addValue
|
||||
42
static/js/ketcher2/node_modules/webdriverio/lib/commands/call.js
generated
vendored
Normal file
42
static/js/ketcher2/node_modules/webdriverio/lib/commands/call.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* You can use `call` to execute any async action within your test spec. The command itself
|
||||
* it treated like a synchronous function. It accepts promises and stops the execution until
|
||||
* the promise has resolved.
|
||||
*
|
||||
* <example>
|
||||
:call.js
|
||||
it('some testing here', function() {
|
||||
browser.url('http://google.com')
|
||||
|
||||
// make an asynchronous call using any 3rd party library supporting promises
|
||||
// e.g. call to backend or db to inject fixture data
|
||||
browser.call(function () {
|
||||
return somePromiseLibrary.someMethod().then(function () {
|
||||
// ...
|
||||
})
|
||||
})
|
||||
|
||||
// example for async call to 3rd party library that doesn't support promises
|
||||
browser.call(function () {
|
||||
return new Promise(function(resolve, reject) {
|
||||
someOtherNodeLibrary.someMethod(param1, function(err, res) {
|
||||
if (err) {
|
||||
return reject(err)
|
||||
}
|
||||
|
||||
resolve(res)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// continue synchronously
|
||||
browser.click('#elemA')
|
||||
browser.setValue('.firstname','webdriverbot')
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.call
|
||||
* @param {Function} callback function to be called
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
59
static/js/ketcher2/node_modules/webdriverio/lib/commands/chooseFile.js
generated
vendored
Normal file
59
static/js/ketcher2/node_modules/webdriverio/lib/commands/chooseFile.js
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
*
|
||||
* Given a selector corresponding to an `<input type=file>` chooseFile will upload
|
||||
* the local file to the browser machine and fill the form accordingly. It does not
|
||||
* submit the form for you. This command only works for desktop browser.
|
||||
*
|
||||
* <example>
|
||||
:call.js
|
||||
it('uploads a file and fills the form with it', async function () {
|
||||
var toUpload = path.join(__dirname, '..', '..', 'fixtures', 'cat-to-upload.gif')
|
||||
|
||||
browser.chooseFile('#upload-test', toUpload)
|
||||
|
||||
browser.getValue('#upload-test')
|
||||
expect(/cat\-to\-upload\.gif$/.test(val)).to.be.equal(true)
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.chooseFile
|
||||
* @param {String} selector input element
|
||||
* @param {String} localPath local path to file to be uploaded
|
||||
* @uses utility/uploadFile, action/addValue
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
import fs from 'fs'
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let chooseFile = function (selector, localPath) {
|
||||
/*!
|
||||
* parameter check
|
||||
*/
|
||||
if (typeof localPath !== 'string') {
|
||||
return new CommandError('number or type of arguments don\'t agree with chooseFile command')
|
||||
}
|
||||
|
||||
/*!
|
||||
* mobile check
|
||||
*/
|
||||
if (this.isMobile) {
|
||||
return new CommandError('chooseFile command is not supported on mobile platforms')
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.stat(localPath, (err) => {
|
||||
/* istanbul ignore next */
|
||||
if (err) {
|
||||
return reject(new CommandError('File to upload does not exists on your system'))
|
||||
}
|
||||
|
||||
this.uploadFile(localPath).then(function (res) {
|
||||
return this.addValue(selector, res.value)
|
||||
}).then(resolve, reject)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default chooseFile
|
||||
48
static/js/ketcher2/node_modules/webdriverio/lib/commands/clearElement.js
generated
vendored
Normal file
48
static/js/ketcher2/node_modules/webdriverio/lib/commands/clearElement.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
*
|
||||
* Clear a `<textarea>` or text `<input>` element’s value. Make sure you can interact with the
|
||||
* element before using this command. You can't clear an input element that is disabled or in
|
||||
* readonly mode.
|
||||
*
|
||||
* <example>
|
||||
:clearElement.js
|
||||
it('should demonstrate the clearElement command', function () {
|
||||
var input = $('.input')
|
||||
input.setValue('test123')
|
||||
console.log(input.getValue()) // returns 'test123'
|
||||
|
||||
input.clearElement()
|
||||
// or
|
||||
browser.clearElement('.input')
|
||||
|
||||
var value = browser.getValue('.input')
|
||||
assert(value === ''); // true
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.clearElement
|
||||
* @param {String} selector input element
|
||||
* @uses protocol/elements, protocol/elementIdClear
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let clearElement = function (selector) {
|
||||
return this.elements(selector).then((res) => {
|
||||
if (!res.value || res.value.length === 0) {
|
||||
// throw NoSuchElement error if no element was found
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
let elementIdClearCommands = []
|
||||
for (let elem of res.value) {
|
||||
elementIdClearCommands.push(this.elementIdClear(elem.ELEMENT, 'value'))
|
||||
}
|
||||
|
||||
return this.unify(elementIdClearCommands)
|
||||
})
|
||||
}
|
||||
|
||||
export default clearElement
|
||||
53
static/js/ketcher2/node_modules/webdriverio/lib/commands/click.js
generated
vendored
Normal file
53
static/js/ketcher2/node_modules/webdriverio/lib/commands/click.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
*
|
||||
* Click on an element based on given selector.
|
||||
*
|
||||
* <example>
|
||||
:example.html
|
||||
<button id="myButton" onclick="document.getElementById('someText').innerHTML='I was clicked'">Click me</button>
|
||||
<div id="someText">I was not clicked</div>
|
||||
|
||||
:click.js
|
||||
it('should demonstrate the click command', function () {
|
||||
var myButton = $('#myButton')
|
||||
myButton.click()
|
||||
// or
|
||||
browser.click('#myButton')
|
||||
|
||||
var text = browser.getText('#someText');
|
||||
assert(text === 'I was clicked'); // true
|
||||
})
|
||||
|
||||
:example.js
|
||||
it('should fetch menu links and visit each page', function () {
|
||||
links = $$('#menu a');
|
||||
|
||||
links.forEach(function (link) {
|
||||
link.click();
|
||||
});
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.click
|
||||
* @param {String} selector element to click on. If it matches with more than one DOM-element it automatically clicks on the first element
|
||||
* @uses protocol/element, protocol/elementIdClick
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
import { RuntimeError } from '../utils/ErrorHandler'
|
||||
|
||||
let click = function (selector) {
|
||||
return this.element(selector).then((elem) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!elem.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
return this.elementIdClick(elem.value.ELEMENT)
|
||||
})
|
||||
}
|
||||
|
||||
export default click
|
||||
47
static/js/ketcher2/node_modules/webdriverio/lib/commands/close.js
generated
vendored
Normal file
47
static/js/ketcher2/node_modules/webdriverio/lib/commands/close.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
*
|
||||
* Close current window (and focus on an other window). If no window handle is given
|
||||
* it automatically switches back to the first handle.
|
||||
*
|
||||
* <example>
|
||||
:close.js
|
||||
it('should demonstrate the close command', function () {
|
||||
browser.url('http://github.com')
|
||||
browser.newWindow('http://google.com')
|
||||
|
||||
var title = browser.getTitle()
|
||||
console.log(title) // outputs: "Google"
|
||||
|
||||
browser.close()
|
||||
|
||||
title = browser.getTitle()
|
||||
console.log(title) // outputs: "GitHub · Build software better, together."
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.close
|
||||
* @param {String=} windowHandle new window to focus on
|
||||
* @uses protocol/window, window/switchTab
|
||||
* @type window
|
||||
*
|
||||
*/
|
||||
|
||||
import { RuntimeError } from '../utils/ErrorHandler'
|
||||
|
||||
let close = function (windowHandle) {
|
||||
if (typeof windowHandle !== 'string') {
|
||||
return this.getTabIds().then((tabIds) => {
|
||||
if (tabIds.length === 0) {
|
||||
throw new RuntimeError('' +
|
||||
'Can\'t switch to the next tab because all windows are closed. ' +
|
||||
'Make sure you keep at least one window open!')
|
||||
}
|
||||
|
||||
return this.window().switchTab(tabIds[0])
|
||||
})
|
||||
}
|
||||
|
||||
return this.window().switchTab(windowHandle)
|
||||
}
|
||||
|
||||
export default close
|
||||
115
static/js/ketcher2/node_modules/webdriverio/lib/commands/debug.js
generated
vendored
Normal file
115
static/js/ketcher2/node_modules/webdriverio/lib/commands/debug.js
generated
vendored
Normal file
@ -0,0 +1,115 @@
|
||||
/**
|
||||
*
|
||||
* This command helps you to debug your integration tests. It stops the running browser and gives
|
||||
* you time to jump into it and check the state of your application (e.g. using the dev tools).
|
||||
* Your terminal transforms into a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)
|
||||
* interface that will allow you to try out certain commands, find elements and test actions on
|
||||
* them.
|
||||
*
|
||||
* [](http://webdriver.io/images/repl.gif)
|
||||
*
|
||||
* If you run the WDIO testrunner make sure you increase the timeout property of your test framework
|
||||
* your are using (e.g. Mocha or Jasmine) in order to prevent the continuation due to a test timeout.
|
||||
* Also avoid to execute the command with multiple capabilities running at the same time.
|
||||
*
|
||||
* <iframe width="560" height="315" src="https://www.youtube.com/embed/xWwP-3B_YyE" frameborder="0" allowfullscreen></iframe>
|
||||
*
|
||||
* <example>
|
||||
:debug.js
|
||||
it('should demonstrate the debug command', function () {
|
||||
browser.setValue('#input', 'FOO')
|
||||
|
||||
browser.debug() // jumping into the browser and change value of #input to 'BAR'
|
||||
|
||||
var value = browser.getValue('#input')
|
||||
console.log(value) // outputs: "BAR"
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.debug
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
import vm from 'vm'
|
||||
import repl from 'repl'
|
||||
import { RuntimeError } from '../utils/ErrorHandler'
|
||||
|
||||
let debug = function (commandTimeout = 5000, enableStdout, enableLogging) {
|
||||
let commandIsRunning = false
|
||||
let logLevel = this.logger.logLevel
|
||||
this.logger.logLevel = 'verbose'
|
||||
this.logger.debug()
|
||||
|
||||
if (!enableLogging) {
|
||||
this.logger.logLevel = logLevel
|
||||
}
|
||||
|
||||
const myEval = (cmd, context, filename, callback) => {
|
||||
if (commandIsRunning) {
|
||||
return
|
||||
}
|
||||
|
||||
if (cmd === 'browser\n') {
|
||||
return callback(null, '[WebdriverIO REPL client]')
|
||||
}
|
||||
|
||||
commandIsRunning = true
|
||||
let result
|
||||
if (typeof global.wdioSync === 'function') {
|
||||
return global.wdioSync(() => {
|
||||
try {
|
||||
result = vm.runInThisContext(cmd)
|
||||
} catch (e) {
|
||||
commandIsRunning = false
|
||||
return callback(e)
|
||||
}
|
||||
|
||||
callback(null, result)
|
||||
commandIsRunning = false
|
||||
})()
|
||||
}
|
||||
|
||||
context.browser = this
|
||||
try {
|
||||
result = vm.runInThisContext(cmd)
|
||||
} catch (e) {
|
||||
commandIsRunning = false
|
||||
return callback(e)
|
||||
}
|
||||
|
||||
if (!result || typeof result.then !== 'function') {
|
||||
commandIsRunning = false
|
||||
return callback(null, result)
|
||||
}
|
||||
|
||||
const timeout = setTimeout(() => callback(new RuntimeError('Command execution timed out')), commandTimeout)
|
||||
result.then((res) => {
|
||||
commandIsRunning = false
|
||||
clearTimeout(timeout)
|
||||
return callback(null, res)
|
||||
}, (e) => {
|
||||
commandIsRunning = false
|
||||
clearTimeout(timeout)
|
||||
return callback(e)
|
||||
})
|
||||
}
|
||||
|
||||
const replServer = repl.start({
|
||||
prompt: '> ',
|
||||
eval: myEval,
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
useGlobal: true,
|
||||
ignoreUndefined: true
|
||||
})
|
||||
|
||||
return new Promise((resolve) => {
|
||||
replServer.on('exit', () => {
|
||||
this.logger.logLevel = logLevel
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default debug
|
||||
54
static/js/ketcher2/node_modules/webdriverio/lib/commands/deleteCookie.js
generated
vendored
Normal file
54
static/js/ketcher2/node_modules/webdriverio/lib/commands/deleteCookie.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
*
|
||||
* Delete cookies visible to the current page. By providing a cookie name it just removes the single cookie.
|
||||
*
|
||||
* <example>
|
||||
:deleteCookie.js
|
||||
it('should delete cookies', function () {
|
||||
browser.setCookie({name: 'test', value: '123'})
|
||||
browser.setCookie({name: 'test2', value: '456'})
|
||||
browser.setCookie({name: 'test3', value: '789'})
|
||||
|
||||
var cookies = browser.getCookie()
|
||||
console.log(cookies)
|
||||
// outputs:
|
||||
// [
|
||||
// { name: 'test', value: '123' },
|
||||
// { name: 'test2', value: '456' }
|
||||
// { name: 'test3', value: '789' }
|
||||
// ]
|
||||
|
||||
browser.deleteCookie('test3')
|
||||
cookies = browser.getCookie()
|
||||
console.log(cookies)
|
||||
// outputs:
|
||||
// [
|
||||
// { name: 'test', value: '123' },
|
||||
// { name: 'test2', value: '456' }
|
||||
// ]
|
||||
|
||||
browser.deleteCookie()
|
||||
cookies = browser.getCookie()
|
||||
console.log(cookies) // outputs: []
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.deleteCookie
|
||||
* @param {String=} name name of cookie to be deleted
|
||||
* @uses protocol/cookie
|
||||
* @type cookie
|
||||
*
|
||||
*/
|
||||
|
||||
let deleteCookie = function (name) {
|
||||
/*!
|
||||
* parameter check
|
||||
*/
|
||||
if (typeof name !== 'string') {
|
||||
name = null
|
||||
}
|
||||
|
||||
return this.cookie('DELETE', name)
|
||||
}
|
||||
|
||||
export default deleteCookie
|
||||
57
static/js/ketcher2/node_modules/webdriverio/lib/commands/doubleClick.js
generated
vendored
Normal file
57
static/js/ketcher2/node_modules/webdriverio/lib/commands/doubleClick.js
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
/**
|
||||
*
|
||||
* Double-click on an element based on given selector.
|
||||
*
|
||||
* <example>
|
||||
:example.html
|
||||
<button id="myButton" ondblclick="document.getElementById('someText').innerHTML='I was dblclicked'">Click me</button>
|
||||
<div id="someText">I was not clicked</div>
|
||||
|
||||
:doubleClick.js
|
||||
it('should demonstrate the doubleClick command', function () {
|
||||
var myButton = $('#myButton')
|
||||
myButton.doubleClick()
|
||||
// or
|
||||
browser.doubleClick('#myButton')
|
||||
|
||||
var value = browser.getText('#someText')
|
||||
assert(value === 'I was dblclicked') // true
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.doubleClick
|
||||
* @param {String} selector element to double click on. If it matches with more than on DOM-element it automatically clicks on the first element
|
||||
* @uses protocol/element, protocol/moveTo, protocol/doDoubleClick, protocol/touchDoubleClick
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
import { RuntimeError } from '../utils/ErrorHandler'
|
||||
|
||||
let doubleClick = function (selector) {
|
||||
if (this.isMobile) {
|
||||
return this.element(selector).then((res) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!res.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
return this.touchDoubleClick(res.value.ELEMENT)
|
||||
})
|
||||
}
|
||||
|
||||
return this.element(selector).then((res) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!res.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
return this.moveTo(res.value.ELEMENT)
|
||||
}).doDoubleClick()
|
||||
}
|
||||
|
||||
export default doubleClick
|
||||
26
static/js/ketcher2/node_modules/webdriverio/lib/commands/dragAndDrop.js
generated
vendored
Normal file
26
static/js/ketcher2/node_modules/webdriverio/lib/commands/dragAndDrop.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
*
|
||||
* Drag an item to a destination element. __Note:__ this command only works for some drag&drop implementation
|
||||
* and some browser because of the way how Selenium simulates mouse events.
|
||||
*
|
||||
* @alias browser.dragAndDrop
|
||||
* @param {String} sourceElem source selector
|
||||
* @param {String} destinationElem destination selector
|
||||
* @uses action/moveToObject, protocol/buttonDown, protocol/buttonUp, property/getLocation, protocol/touchDown, protocol/touchMove, protocol/touchUp
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
let dragAndDrop = function (selector, destinationElem) {
|
||||
if (this.isMobile) {
|
||||
return this.getLocation(selector).then(
|
||||
(location) => this.touchDown(location.x, location.y)
|
||||
).getLocation(destinationElem).then(
|
||||
(location) => this.touchMove(location.x, location.y).touchUp(location.x, location.y)
|
||||
)
|
||||
}
|
||||
|
||||
return this.moveToObject(selector).buttonDown().moveToObject(destinationElem).buttonUp()
|
||||
}
|
||||
|
||||
export default dragAndDrop
|
||||
29
static/js/ketcher2/node_modules/webdriverio/lib/commands/end.js
generated
vendored
Normal file
29
static/js/ketcher2/node_modules/webdriverio/lib/commands/end.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
*
|
||||
* End the session and close browser. This command is only supported in standalone mode. If you
|
||||
* are using the wdio testrunner you can't close the browser before your spec finishes. The testrunner
|
||||
* will close the browser for you after the spec has finished.
|
||||
*
|
||||
* However if you want to refresh the browser session you can try the [`reload`](/api/utility/reload.html)
|
||||
* command.
|
||||
*
|
||||
* <example>
|
||||
:endAsync.js
|
||||
client
|
||||
.init() // starts session and opens the browser
|
||||
.url('http://google.com')
|
||||
// ... other commands
|
||||
.end(); // ends session and close browser
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.end
|
||||
* @uses protocol/session
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
let end = function () {
|
||||
return this.session('delete')
|
||||
}
|
||||
|
||||
export default end
|
||||
24
static/js/ketcher2/node_modules/webdriverio/lib/commands/endAll.js
generated
vendored
Normal file
24
static/js/ketcher2/node_modules/webdriverio/lib/commands/endAll.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
*
|
||||
* End all selenium server sessions at once. Like the [`end`](/api/utility/end.html) command is this command
|
||||
* only supported in standalone mode.
|
||||
*
|
||||
* @alias browser.endAll
|
||||
* @uses protocol/sessions, protocol/session
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
let endAll = function () {
|
||||
return this.sessions().then((res) => {
|
||||
let sessionCommands = []
|
||||
|
||||
for (let session of res.value) {
|
||||
sessionCommands.push(this.session('delete', session.id))
|
||||
}
|
||||
|
||||
return this.unify(sessionCommands)
|
||||
})
|
||||
}
|
||||
|
||||
export default endAll
|
||||
68
static/js/ketcher2/node_modules/webdriverio/lib/commands/getAttribute.js
generated
vendored
Normal file
68
static/js/ketcher2/node_modules/webdriverio/lib/commands/getAttribute.js
generated
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
/**
|
||||
*
|
||||
* Get an attribute from an DOM-element based on the selector and attribute name.
|
||||
* Returns a list of attribute values if selector matches multiple elements.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<form action="/submit" method="post" class="loginForm">
|
||||
<input type="text" name="name" placeholder="username"></input>
|
||||
<input type="text" name="password" placeholder="password"></input>
|
||||
<input type="submit" name="submit" value="submit"></input>
|
||||
</form>
|
||||
|
||||
:getAttribute.js
|
||||
it('should demonstrate the getAttribute command', function () {
|
||||
var form = $('form')
|
||||
|
||||
var attr = form.getAttribute('method')
|
||||
console.log(attr) // outputs: "post"
|
||||
// or
|
||||
console.log(browser.getAttribute('form', 'method')) // outputs: "post"
|
||||
|
||||
// if your selector matches multiple elements it returns an array of results
|
||||
var allInputs = $$('.loginForm input')
|
||||
console.log(allInputs.map(function(el) { return el.getAttribute('name'); })) // outputs: ['name', 'password', 'submit']
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getAttribute
|
||||
* @param {String} selector element with requested attribute
|
||||
* @param {String} attributeName requested attribute
|
||||
* @return {String|String[]|null} The value of the attribute(s), or null if it is not set on the element.
|
||||
* @uses protocol/elements, protocol/elementIdAttribute
|
||||
* @type property
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let getAttribute = function (selector, attributeName) {
|
||||
/*!
|
||||
* parameter check
|
||||
*/
|
||||
if (typeof attributeName !== 'string') {
|
||||
throw new CommandError('number or type of arguments don\'t agree with getAttribute command')
|
||||
}
|
||||
|
||||
return this.elements(selector).then((res) => {
|
||||
/**
|
||||
* throw NoSuchElement error if no element was found
|
||||
*/
|
||||
if (!res.value || res.value.length === 0) {
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
let elementIdAttributeCommands = []
|
||||
|
||||
for (let elem of res.value) {
|
||||
elementIdAttributeCommands.push(this.elementIdAttribute(elem.ELEMENT, attributeName))
|
||||
}
|
||||
|
||||
return this.unify(elementIdAttributeCommands, {
|
||||
extractValue: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default getAttribute
|
||||
77
static/js/ketcher2/node_modules/webdriverio/lib/commands/getCommandHistory.js
generated
vendored
Normal file
77
static/js/ketcher2/node_modules/webdriverio/lib/commands/getCommandHistory.js
generated
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
/**
|
||||
*
|
||||
* Returns a list of previous called commands + their arguments and execution timestamp.
|
||||
*
|
||||
* <example>
|
||||
:getCommandHistoryAsync.js
|
||||
client
|
||||
.init()
|
||||
.url('http://www.google.com')
|
||||
.click('#username')
|
||||
.addValue('#password', 'text')
|
||||
.pause(2000)
|
||||
.getCommandHistory().then(function(history){
|
||||
console.log(history);
|
||||
// outputs:
|
||||
// [ { name: 'init', args: [], timestamp: 1487078962707 },
|
||||
// { name: 'url', args: [ 'http://www.google.com' ], timestamp: 1487078962707 },
|
||||
// { name: 'click', args: [ 'body' ], timestamp: 1487078962707 },
|
||||
// { name: 'element',
|
||||
// args: [ 'body' ],
|
||||
// timestamp: 1487078962707,
|
||||
// result:
|
||||
// { state: 'success',
|
||||
// sessionId: 'c2aea856-ba18-48c0-8745-aa292f6394bc',
|
||||
// hCode: 1094372184,
|
||||
// value: [Object],
|
||||
// class: 'org.openqa.selenium.remote.Response',
|
||||
// status: 0,
|
||||
// selector: 'body' } },
|
||||
// { name: 'elementIdClick',
|
||||
// args: [ '0' ],
|
||||
// timestamp: 1487078962707,
|
||||
// result:
|
||||
// { state: 'success',
|
||||
// sessionId: 'c2aea856-ba18-48c0-8745-aa292f6394bc',
|
||||
// hCode: 1704637158,
|
||||
// value: null,
|
||||
// class: 'org.openqa.selenium.remote.Response',
|
||||
// status: 0 } },
|
||||
// { name: 'addValue', args: [ '#lst-ib', 'webdriverio' ], timestamp: 1487078962707 },
|
||||
// { name: 'elements',
|
||||
// args: [ '#lst-ib' ],
|
||||
// timestamp: 1487078962707,
|
||||
// result:
|
||||
// { state: 'success',
|
||||
// sessionId: 'c2aea856-ba18-48c0-8745-aa292f6394bc',
|
||||
// hCode: 1171202369,
|
||||
// value: [Object],
|
||||
// class: 'org.openqa.selenium.remote.Response',
|
||||
// status: 0,
|
||||
// selector: '#lst-ib' } },
|
||||
// { name: 'elementIdValue',
|
||||
// args: [ '1', 'webdriverio' ],
|
||||
// timestamp: 1487078962707,
|
||||
// result:
|
||||
// { state: 'success',
|
||||
// sessionId: 'c2aea856-ba18-48c0-8745-aa292f6394bc',
|
||||
// hCode: 447115314,
|
||||
// value: null,
|
||||
// class: 'org.openqa.selenium.remote.Response',
|
||||
// status: 0 } },
|
||||
// { name: 'pause', args: [ 2000 ], timestamp: 1487078962707 } ]
|
||||
})
|
||||
.end();
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getCommandHistory
|
||||
* @return {Object[]} list of recent called commands + their arguments
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
let getCommandHistory = function () {
|
||||
return this.commandList.slice(0, -1)
|
||||
}
|
||||
|
||||
export default getCommandHistory
|
||||
53
static/js/ketcher2/node_modules/webdriverio/lib/commands/getCookie.js
generated
vendored
Normal file
53
static/js/ketcher2/node_modules/webdriverio/lib/commands/getCookie.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
*
|
||||
* Retrieve a [cookie](https://w3c.github.io/webdriver/webdriver-spec.html#cookies)
|
||||
* visible to the current page. You can query a specific cookie by providing the cookie name or
|
||||
* retrieve all.
|
||||
*
|
||||
* <example>
|
||||
:getCookie.js
|
||||
it('should return a cookie for me', function () {
|
||||
browser.setCookie({name: 'test', value: '123'})
|
||||
browser.setCookie({name: 'test2', value: '456'})
|
||||
|
||||
var testCookie = browser.getCookie('test')
|
||||
console.log(testCookie); // outputs: { name: 'test', value: '123' }
|
||||
|
||||
var allCookies = browser.getCookie()
|
||||
console.log(allCookies);
|
||||
// outputs:
|
||||
// [
|
||||
// { name: 'test', value: '123' },
|
||||
// { name: 'test2', value: '456' }
|
||||
// ]
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getCookie
|
||||
* @param {String=} name name of requested cookie
|
||||
* @return {Object|null} requested cookie if existing
|
||||
* @uses protocol/cookie
|
||||
* @type cookie
|
||||
*
|
||||
*/
|
||||
|
||||
let getCookie = function (name) {
|
||||
/*!
|
||||
* paramter check
|
||||
*/
|
||||
if (typeof name !== 'string') {
|
||||
name = null
|
||||
}
|
||||
|
||||
return this.cookie().then((res) => {
|
||||
res.value = res.value || []
|
||||
|
||||
if (typeof name === 'string') {
|
||||
return res.value.filter((cookie) => cookie.name === name)[0] || null
|
||||
}
|
||||
|
||||
return res.value || (typeof name === 'string' ? null : [])
|
||||
})
|
||||
}
|
||||
|
||||
export default getCookie
|
||||
105
static/js/ketcher2/node_modules/webdriverio/lib/commands/getCssProperty.js
generated
vendored
Normal file
105
static/js/ketcher2/node_modules/webdriverio/lib/commands/getCssProperty.js
generated
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
/**
|
||||
*
|
||||
* Get a css property from a DOM-element selected by given selector. The return value
|
||||
* is formatted to be testable. Colors gets parsed via [rgb2hex](https://www.npmjs.org/package/rgb2hex)
|
||||
* and all other properties get parsed via [css-value](https://www.npmjs.org/package/css-value).
|
||||
*
|
||||
* Note that shorthand CSS properties (e.g. background, font, border, margin, padding, list-style, outline,
|
||||
* pause, cue) are not returned, in accordance with the DOM CSS2 specification - you should directly access
|
||||
* the longhand properties (e.g. background-color) to access the desired values.
|
||||
*
|
||||
* <example>
|
||||
:example.html
|
||||
<label id="myLabel" for="input" style="color: #0088cc; font-family: helvetica, arial, freesans, clean, sans-serif, width: 100px">Some Label</label>
|
||||
|
||||
:getCssProperty.js
|
||||
it('should demonstrate the getCssProperty command', function () {
|
||||
var elem = $('#myLabel')
|
||||
|
||||
var color = elem.getCssProperty('color')
|
||||
console.log(color)
|
||||
// outputs the following:
|
||||
// {
|
||||
// property: 'color',
|
||||
// value: 'rgba(0, 136, 204, 1)',
|
||||
// parsed: {
|
||||
// hex: '#0088cc',
|
||||
// alpha: 1,
|
||||
// type: 'color',
|
||||
// rgba: 'rgba(0, 136, 204, 1)'
|
||||
// }
|
||||
// }
|
||||
|
||||
var font = elem.getCssProperty('font-family')
|
||||
console.log(font)
|
||||
// outputs the following:
|
||||
// {
|
||||
// property: 'font-family',
|
||||
// value: 'helvetica',
|
||||
// parsed: {
|
||||
// value: [ 'helvetica', 'arial', 'freesans', 'clean', 'sans-serif' ],
|
||||
// type: 'font',
|
||||
// string: 'helvetica, arial, freesans, clean, sans-serif'
|
||||
// }
|
||||
// }
|
||||
|
||||
var width = elem.getCssProperty('width')
|
||||
console.log(width)
|
||||
// outputs the following:
|
||||
// {
|
||||
// property: 'width',
|
||||
// value: '100px',
|
||||
// parsed: {
|
||||
// type: 'number',
|
||||
// string: '100px',
|
||||
// unit: 'px',
|
||||
// value: 100
|
||||
// }
|
||||
// }
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getCssProperty
|
||||
* @param {String} selector element with requested style attribute
|
||||
* @param {String} cssProperty css property name
|
||||
* @uses protocol/elements, protocol/elementIdCssProperty
|
||||
* @type property
|
||||
*
|
||||
*/
|
||||
|
||||
import parseCSS from '../helpers/parseCSS.js'
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let getCssProperty = function (selector, cssProperty) {
|
||||
/*!
|
||||
* parameter check
|
||||
*/
|
||||
if (typeof cssProperty !== 'string') {
|
||||
throw new CommandError('number or type of arguments don\'t agree with getCssProperty command')
|
||||
}
|
||||
|
||||
return this.elements(selector).then((res) => {
|
||||
if (!res.value || res.value.length === 0) {
|
||||
// throw NoSuchElement error if no element was found
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
let elementIdCssPropertyCommands = []
|
||||
for (let elem of res.value) {
|
||||
elementIdCssPropertyCommands.push(this.elementIdCssProperty(elem.ELEMENT, cssProperty))
|
||||
}
|
||||
|
||||
return Promise.all(elementIdCssPropertyCommands)
|
||||
}).then((result) => {
|
||||
/**
|
||||
* result already unwrapped when command was reran
|
||||
*/
|
||||
if (!Array.isArray(result)) {
|
||||
return result
|
||||
}
|
||||
|
||||
return parseCSS(result, cssProperty)
|
||||
})
|
||||
}
|
||||
|
||||
export default getCssProperty
|
||||
30
static/js/ketcher2/node_modules/webdriverio/lib/commands/getCurrentTabId.js
generated
vendored
Normal file
30
static/js/ketcher2/node_modules/webdriverio/lib/commands/getCurrentTabId.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
*
|
||||
* Retrieve the current window handle.
|
||||
*
|
||||
* <example>
|
||||
:getCurrenteTabId.js
|
||||
it('should return the current tab id', function () {
|
||||
browser.url('http://webdriver.io')
|
||||
|
||||
var tabId = browser.getCurrentTabId()
|
||||
console.log(tabid)
|
||||
// outputs something like the following:
|
||||
// "CDwindow-C43FB686-949D-4232-828B-583398FBD0C0"
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getCurrentTabId
|
||||
* @return {String} the window handle URL of the current focused window
|
||||
* @uses protocol/windowHandle
|
||||
* @type window
|
||||
*
|
||||
*/
|
||||
|
||||
let getCurrentTabId = function () {
|
||||
return this.unify(this.windowHandle(), {
|
||||
extractValue: true
|
||||
})
|
||||
}
|
||||
|
||||
export default getCurrentTabId
|
||||
77
static/js/ketcher2/node_modules/webdriverio/lib/commands/getElementSize.js
generated
vendored
Normal file
77
static/js/ketcher2/node_modules/webdriverio/lib/commands/getElementSize.js
generated
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
/**
|
||||
*
|
||||
* Get the width and height for an DOM-element based given selector.
|
||||
*
|
||||
* <example>
|
||||
:getElementSize.js
|
||||
it('should give me the size of an element', function () {
|
||||
browser.url('http://github.com')
|
||||
var logo = $('.octicon-mark-github')
|
||||
|
||||
var size = logo.getElementSize()
|
||||
// or
|
||||
size = browser.getElementSize('.octicon-mark-github')
|
||||
console.log(size) // outputs: { width: 32, height: 32 }
|
||||
|
||||
var width = logo.getElementSize('width')
|
||||
// or
|
||||
width = browser.getElementSize('.octicon-mark-github', 'width')
|
||||
console.log(width) // outputs: 32
|
||||
|
||||
var height = logo.getElementSize('height')
|
||||
// or
|
||||
height = browser.getElementSize('.octicon-mark-github', 'height')
|
||||
console.log(height) // outputs: 32
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getElementSize
|
||||
* @param {String} selector element with requested size
|
||||
* @param {String*} prop size to receive (optional "width|height")
|
||||
* @return {Object|Number} requested element size (`{ width: <Number>, height: <Number> }`) or actual width/height as number if prop param is given
|
||||
* @uses protocol/elements, protocol/elementIdSize
|
||||
* @type property
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let getElementSize = function (selector, prop) {
|
||||
return this.elements(selector).then(function (res) {
|
||||
/**
|
||||
* throw NoSuchElement error if no element was found
|
||||
*/
|
||||
if (!res.value || res.value.length === 0) {
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
let elementIdSizeCommands = []
|
||||
for (let elem of res.value) {
|
||||
elementIdSizeCommands.push(this.elementIdSize(elem.ELEMENT))
|
||||
}
|
||||
|
||||
return Promise.all(elementIdSizeCommands)
|
||||
}).then((sizes) => {
|
||||
/**
|
||||
* result already unwrapped when command was reran
|
||||
*/
|
||||
if (!Array.isArray(sizes)) {
|
||||
return sizes
|
||||
}
|
||||
|
||||
sizes = sizes.map((size) => {
|
||||
if (typeof prop === 'string' && prop.match(/(width|height)/)) {
|
||||
return size.value[prop]
|
||||
}
|
||||
|
||||
return {
|
||||
width: size.value.width,
|
||||
height: size.value.height
|
||||
}
|
||||
})
|
||||
|
||||
return sizes.length === 1 ? sizes[0] : sizes
|
||||
})
|
||||
}
|
||||
|
||||
export default getElementSize
|
||||
32
static/js/ketcher2/node_modules/webdriverio/lib/commands/getGeoLocation.js
generated
vendored
Normal file
32
static/js/ketcher2/node_modules/webdriverio/lib/commands/getGeoLocation.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
*
|
||||
* Get the current geolocation.
|
||||
*
|
||||
* <example>
|
||||
:getGeoLocation.js
|
||||
it('should return my current location', function () {
|
||||
var location = browser.getGeoLocation()
|
||||
console.log(location)
|
||||
// outputs:
|
||||
// {
|
||||
// latitude: 51.1045407,
|
||||
// longitude: 13.2017384,
|
||||
// altitude: 20.23345
|
||||
// }
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getGeoLocation
|
||||
* @return {Object} the current geo location (`{latitude: number, longitude: number, altitude: number}`)
|
||||
* @uses protocol/location
|
||||
* @type mobile
|
||||
*
|
||||
*/
|
||||
|
||||
let getGeoLocation = function () {
|
||||
return this.unify(this.location(), {
|
||||
extractValue: true
|
||||
})
|
||||
}
|
||||
|
||||
export default getGeoLocation
|
||||
55
static/js/ketcher2/node_modules/webdriverio/lib/commands/getGridNodeDetails.js
generated
vendored
Normal file
55
static/js/ketcher2/node_modules/webdriverio/lib/commands/getGridNodeDetails.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
*
|
||||
* Get the details of the Selenium Grid node running a session
|
||||
*
|
||||
* <example>
|
||||
:grid.js
|
||||
it('should return grid information', function () {
|
||||
console.log(browser.getGridNodeDetails())
|
||||
// {
|
||||
// success: true,
|
||||
// msg: "proxy found !",
|
||||
// id: "MacMiniA10",
|
||||
// request: {
|
||||
// ...
|
||||
// configuration: {
|
||||
// ...
|
||||
// },
|
||||
// capabilities: [
|
||||
// {
|
||||
// ...
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// }
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getGridNodeDetails
|
||||
* @uses grid/gridTestSession, grid/gridProxyDetails
|
||||
* @type grid
|
||||
*/
|
||||
|
||||
let getGridNodeDetails = function () {
|
||||
return this.gridTestSession().then((session) =>
|
||||
this.gridProxyDetails(session.proxyId).then((details) => {
|
||||
delete session.msg
|
||||
delete session.success
|
||||
|
||||
delete details.msg
|
||||
delete details.success
|
||||
delete details.id
|
||||
|
||||
return Object.assign(details, session)
|
||||
})
|
||||
)
|
||||
.catch(e => {
|
||||
if (e.seleniumStack && e.seleniumStack.type === 'GridApiError') {
|
||||
return {
|
||||
error: e.message
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default getGridNodeDetails
|
||||
55
static/js/ketcher2/node_modules/webdriverio/lib/commands/getHTML.js
generated
vendored
Normal file
55
static/js/ketcher2/node_modules/webdriverio/lib/commands/getHTML.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
*
|
||||
* Get source code of specified DOM element by selector.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<div id="test">
|
||||
<span>Lorem ipsum dolor amet</span>
|
||||
</div>
|
||||
|
||||
:getHTML.js
|
||||
it('should get html for certain elements', function () {
|
||||
var outerHTML = browser.getHTML('#test');
|
||||
console.log(outerHTML);
|
||||
// outputs:
|
||||
// "<div id="test"><span>Lorem ipsum dolor amet</span></div>"
|
||||
|
||||
var innerHTML = browser.getHTML('#test', false);
|
||||
console.log(innerHTML);
|
||||
// outputs:
|
||||
// "<span>Lorem ipsum dolor amet</span>"
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getHTML
|
||||
* @param {String} selector element to get the current DOM structure from
|
||||
* @param {Boolean=} includeSelectorTag if true it includes the selector element tag (default: true)
|
||||
* @uses action/selectorExecute
|
||||
* @type property
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
import getHTMLHelper from '../scripts/getHTML'
|
||||
|
||||
let getHTML = function (selector, includeSelectorTag) {
|
||||
/**
|
||||
* we can't use default values for function parameter here because this would
|
||||
* break the ability to chain the command with an element if includeSelectorTag is used
|
||||
*/
|
||||
includeSelectorTag = typeof includeSelectorTag === 'boolean' ? includeSelectorTag : true
|
||||
|
||||
return this.selectorExecute(selector, getHTMLHelper, includeSelectorTag).then((html) => {
|
||||
/**
|
||||
* throw NoSuchElement error if no element was found
|
||||
*/
|
||||
if (!html) {
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
return html && html.length === 1 ? html[0] : html
|
||||
})
|
||||
}
|
||||
|
||||
export default getHTML
|
||||
83
static/js/ketcher2/node_modules/webdriverio/lib/commands/getLocation.js
generated
vendored
Normal file
83
static/js/ketcher2/node_modules/webdriverio/lib/commands/getLocation.js
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
*
|
||||
* Determine an element’s location on the page. The point (0, 0) refers to
|
||||
* the upper-left corner of the page.
|
||||
*
|
||||
* <example>
|
||||
:getLocation.js
|
||||
it('should get the location of one or multiple elements', function () {
|
||||
browser.url('http://github.com');
|
||||
|
||||
var location = browser.getLocation('.octicon-mark-github');
|
||||
console.log(location); // outputs: { x: 150, y: 20 }
|
||||
|
||||
var xLocation = browser.getLocation('.octicon-mark-github', 'x')
|
||||
console.log(xLocation); // outputs: 150
|
||||
|
||||
var yLocation = browser.getLocation('.octicon-mark-github', 'y')
|
||||
console.log(yLocation); // outputs: 20
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getLocation
|
||||
* @param {String} selector element with requested position offset
|
||||
* @param {String} property can be "x" or "y" to get a result value directly for easier assertions
|
||||
* @return {Object|Object[]} The X and Y coordinates for the element on the page (`{x:number, y:number}`)
|
||||
* @uses protocol/elements, protocol/elementIdLocation
|
||||
* @type property
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let getLocation = function (selector, prop) {
|
||||
return this.elements(selector).then((res) => {
|
||||
/**
|
||||
* throw NoSuchElement error if no element was found
|
||||
*/
|
||||
if (!res.value || res.value.length === 0) {
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
let results = []
|
||||
let that = this
|
||||
return new Promise((resolve, reject) => {
|
||||
let hasError = false
|
||||
|
||||
function processNext () {
|
||||
let current = res.value.pop()
|
||||
|
||||
return that
|
||||
.elementIdLocation(current.ELEMENT)
|
||||
.catch((err) => {
|
||||
hasError = true
|
||||
reject(err)
|
||||
})
|
||||
.then((location) => {
|
||||
if (hasError) {
|
||||
return
|
||||
}
|
||||
|
||||
if (prop === 'x' || prop === 'y') {
|
||||
results.push(location.value[prop])
|
||||
} else {
|
||||
results.push({
|
||||
x: location.value.x,
|
||||
y: location.value.y
|
||||
})
|
||||
}
|
||||
|
||||
if (res.value.length) {
|
||||
return processNext()
|
||||
} else {
|
||||
resolve((results.length === 1) ? results[0] : results)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return processNext()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default getLocation
|
||||
70
static/js/ketcher2/node_modules/webdriverio/lib/commands/getLocationInView.js
generated
vendored
Normal file
70
static/js/ketcher2/node_modules/webdriverio/lib/commands/getLocationInView.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
/**
|
||||
*
|
||||
* Determine an element’s location on the screen once it has been scrolled into view.
|
||||
*
|
||||
* <example>
|
||||
:getLocationInView.js
|
||||
it('should get the location of one or multiple elements in view', function () {
|
||||
browser.url('http://github.com');
|
||||
|
||||
var location = browser.getLocationInView('.octicon-mark-github');
|
||||
console.log(location); // outputs: { x: 150, y: 20 }
|
||||
|
||||
var xLocation = browser.getLocationInView('.octicon-mark-github', 'x')
|
||||
console.log(xLocation); // outputs: 150
|
||||
|
||||
var yLocation = browser.getLocationInView('.octicon-mark-github', 'y')
|
||||
console.log(yLocation); // outputs: 20
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getLocationInView
|
||||
* @param {String} selector element with requested position offset
|
||||
* @return {Object|Object[]} The X and Y coordinates for the element on the page (`{x:number, y:number}`)
|
||||
*
|
||||
* @uses protocol/elements, protocol/elementIdLocationInView
|
||||
* @type property
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let getLocationInView = function (selector, prop) {
|
||||
return this.elements(selector).then((res) => {
|
||||
/**
|
||||
* throw NoSuchElement error if no element was found
|
||||
*/
|
||||
if (!res.value || res.value.length === 0) {
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
let elementIdLocationInViewCommands = []
|
||||
for (let elem of res.value) {
|
||||
elementIdLocationInViewCommands.push(this.elementIdLocationInView(elem.ELEMENT))
|
||||
}
|
||||
|
||||
return Promise.all(elementIdLocationInViewCommands)
|
||||
}).then((locations) => {
|
||||
/**
|
||||
* result already unwrapped when command was reran
|
||||
*/
|
||||
if (!Array.isArray(locations)) {
|
||||
return locations
|
||||
}
|
||||
|
||||
locations = locations.map((location) => {
|
||||
if (typeof prop === 'string' && prop.match(/(x|y)/)) {
|
||||
return location.value[prop]
|
||||
}
|
||||
|
||||
return {
|
||||
x: location.value.x,
|
||||
y: location.value.y
|
||||
}
|
||||
})
|
||||
|
||||
return locations.length === 1 ? locations[0] : locations
|
||||
})
|
||||
}
|
||||
|
||||
export default getLocationInView
|
||||
35
static/js/ketcher2/node_modules/webdriverio/lib/commands/getOrientation.js
generated
vendored
Normal file
35
static/js/ketcher2/node_modules/webdriverio/lib/commands/getOrientation.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
*
|
||||
* Get the current browser orientation. This command only works for mobile environments like Android Emulator,
|
||||
* iOS Simulator or on real devices.
|
||||
*
|
||||
* <example>
|
||||
:getOrientation.js
|
||||
it('should get the orientation of my mobile device', function () {
|
||||
var orientation = browser.getOrientation();
|
||||
console.log(orientation); // outputs: "landscape"
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getOrientation
|
||||
* @return {String} device orientation (`landscape/portrait`)
|
||||
* @uses protocol/orientation
|
||||
* @for android, ios
|
||||
* @type mobile
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let getOrientation = function () {
|
||||
if (!this.isMobile) {
|
||||
throw new CommandError('getOrientation command is not supported on non mobile platforms')
|
||||
}
|
||||
|
||||
return this.unify(this.orientation(), {
|
||||
lowercase: true,
|
||||
extractValue: true
|
||||
})
|
||||
}
|
||||
|
||||
export default getOrientation
|
||||
29
static/js/ketcher2/node_modules/webdriverio/lib/commands/getSource.js
generated
vendored
Normal file
29
static/js/ketcher2/node_modules/webdriverio/lib/commands/getSource.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
*
|
||||
* Get source code of the page. This command won't work in mobile environments for native apps. If you running
|
||||
* hybrid tests make sure that you are in the webview before calling this command.
|
||||
*
|
||||
* <example>
|
||||
:getSource.js
|
||||
it('should get the source of the html document', function () {
|
||||
browser.url('http://webdriver.io');
|
||||
|
||||
var source = browser.getSource();
|
||||
console.log(source); // outputs: "<!DOCTYPE html>\n<title>Webdriver.io</title>..."
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getSource
|
||||
* @return {String} source code of current website
|
||||
* @uses protocol/source
|
||||
* @type property
|
||||
*
|
||||
*/
|
||||
|
||||
let getSource = function () {
|
||||
return this.unify(this.source(), {
|
||||
extractValue: true
|
||||
})
|
||||
}
|
||||
|
||||
export default getSource
|
||||
33
static/js/ketcher2/node_modules/webdriverio/lib/commands/getTabIds.js
generated
vendored
Normal file
33
static/js/ketcher2/node_modules/webdriverio/lib/commands/getTabIds.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
*
|
||||
* Retrieve a list of all window handles available in the session. You can use these handles to switch
|
||||
* to a different tab.
|
||||
*
|
||||
* <example>
|
||||
:getTabIds.js
|
||||
it('should get the source of the html document', function () {
|
||||
browser.url('http://webdriver.io');
|
||||
|
||||
var tabIds = browser.getTabIds();
|
||||
console.log(tabIds); // outputs: ['f9b387e0-99bd-11e6-8881-d3174a61fdce']
|
||||
|
||||
browser.newWindow('http://google.com');
|
||||
tabIds = browser.getTabIds();
|
||||
console.log(tabIds); // outputs: ['f9b387e0-99bd-11e6-8881-d3174a61fdce', 'fb4e9a40-99bd-11e6-8881-d3174a61fdce' ]
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getTabIds
|
||||
* @return {String[]} a list of window handles
|
||||
* @uses protocol/windowHandles
|
||||
* @type window
|
||||
*
|
||||
*/
|
||||
|
||||
let getTabIds = function () {
|
||||
return this.unify(this.windowHandles(), {
|
||||
extractValue: true
|
||||
})
|
||||
}
|
||||
|
||||
export default getTabIds
|
||||
48
static/js/ketcher2/node_modules/webdriverio/lib/commands/getTagName.js
generated
vendored
Normal file
48
static/js/ketcher2/node_modules/webdriverio/lib/commands/getTagName.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
*
|
||||
* Get tag name of a DOM-element found by given selector.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<div id="elem">Lorem ipsum</div>
|
||||
|
||||
:getTagName.js
|
||||
it('should demonstrate the getTagName command', function () {
|
||||
var elem = $('#elem');
|
||||
|
||||
var tagName = elem.getTagName();
|
||||
console.log(tagName); // outputs: "div"
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getTagName
|
||||
* @param {String} selector element with requested tag name
|
||||
* @return {String|String[]} the element's tag name, as a lowercase string
|
||||
* @uses protocol/elements, protocol/elementIdName
|
||||
* @type property
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let getTagName = function (selector) {
|
||||
return this.elements(selector).then((res) => {
|
||||
/**
|
||||
* throw NoSuchElement error if no element was found
|
||||
*/
|
||||
if (!res.value || res.value.length === 0) {
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
let elementIdNameCommands = []
|
||||
for (let elem of res.value) {
|
||||
elementIdNameCommands.push(this.elementIdName(elem.ELEMENT))
|
||||
}
|
||||
|
||||
return this.unify(elementIdNameCommands, {
|
||||
extractValue: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default getTagName
|
||||
67
static/js/ketcher2/node_modules/webdriverio/lib/commands/getText.js
generated
vendored
Normal file
67
static/js/ketcher2/node_modules/webdriverio/lib/commands/getText.js
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
/**
|
||||
*
|
||||
* Get the text content from a DOM-element found by given selector. Make sure the element
|
||||
* you want to request the text from [is interactable](http://www.w3.org/TR/webdriver/#interactable)
|
||||
* otherwise you will get an empty string as return value. If the element is disabled or not
|
||||
* visible and you still want to receive the text content use [getHTML](http://webdriver.io/api/property/getHTML.html)
|
||||
* as a workaround.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<div id="elem">
|
||||
Lorem ipsum <strong>dolor</strong> sit amet,<br>
|
||||
consetetur sadipscing elitr
|
||||
</div>
|
||||
<span style="display: none">I am invisible</span>
|
||||
|
||||
:getText.js
|
||||
it('should get text of an element or elements', function () {
|
||||
var text = browser.getText('#elem');
|
||||
console.log(text);
|
||||
// outputs the following:
|
||||
// "Lorem ipsum dolor sit amet,consetetur sadipscing elitr"
|
||||
|
||||
var spanText = browser.getText('span');
|
||||
console.log(text);
|
||||
// outputs "" (empty string) since element is not interactable
|
||||
});
|
||||
|
||||
it('get content from table cell', function () {
|
||||
browser.url('http://the-internet.herokuapp.com/tables');
|
||||
var rows = $$('#table1 tr');
|
||||
var columns = rows[1].$$('td'); // get columns of 2nd row
|
||||
console.log(columns[2].getText()); // get text of 3rd column
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getText
|
||||
* @param {String} selector element with requested text
|
||||
* @return {String|String[]} content of selected element (all HTML tags are removed)
|
||||
* @uses protocol/elements, protocol/elementIdText
|
||||
* @type property
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let getText = function (selector) {
|
||||
return this.elements(selector).then((res) => {
|
||||
/**
|
||||
* throw NoSuchElement error if no element was found
|
||||
*/
|
||||
if (!res.value || res.value.length === 0) {
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
let elementIdTextCommands = []
|
||||
for (let elem of res.value) {
|
||||
elementIdTextCommands.push(this.elementIdText(elem.ELEMENT))
|
||||
}
|
||||
|
||||
return this.unify(elementIdTextCommands, {
|
||||
extractValue: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default getText
|
||||
31
static/js/ketcher2/node_modules/webdriverio/lib/commands/getTitle.js
generated
vendored
Normal file
31
static/js/ketcher2/node_modules/webdriverio/lib/commands/getTitle.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
*
|
||||
* Get the title of current opened website. This command only works for browser environments or on mobile
|
||||
* devices with webview enabled (hybrid tests).
|
||||
*
|
||||
* <example>
|
||||
:getTitle.js
|
||||
it('should get the title of the document', function () {
|
||||
browser.url('http://webdriver.io');
|
||||
|
||||
var title = browser.getTitle()
|
||||
console.log(title);
|
||||
// outputs the following:
|
||||
// "WebdriverIO - WebDriver bindings for Node.js"
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getTitle
|
||||
* @return {String} current page title
|
||||
* @uses protocol/title
|
||||
* @type property
|
||||
*
|
||||
*/
|
||||
|
||||
let getTitle = function () {
|
||||
return this.unify(this.title(), {
|
||||
extractValue: true
|
||||
})
|
||||
}
|
||||
|
||||
export default getTitle
|
||||
30
static/js/ketcher2/node_modules/webdriverio/lib/commands/getUrl.js
generated
vendored
Normal file
30
static/js/ketcher2/node_modules/webdriverio/lib/commands/getUrl.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
*
|
||||
* Get the url of current opened website.
|
||||
*
|
||||
* <example>
|
||||
:getUrl.js
|
||||
it('should get the url of the current page', function () {
|
||||
browser.url('http://webdriver.io');
|
||||
|
||||
var url = browser.getUrl();
|
||||
console.log(url);
|
||||
// outputs the following:
|
||||
// "http://webdriver.io"
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getUrl
|
||||
* @return {String} current page url
|
||||
* @uses protocol/url
|
||||
* @type property
|
||||
*
|
||||
*/
|
||||
|
||||
let getUrl = function () {
|
||||
return this.unify(this.url(), {
|
||||
extractValue: true
|
||||
})
|
||||
}
|
||||
|
||||
export default getUrl
|
||||
48
static/js/ketcher2/node_modules/webdriverio/lib/commands/getValue.js
generated
vendored
Normal file
48
static/js/ketcher2/node_modules/webdriverio/lib/commands/getValue.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
*
|
||||
* Get the value of a `<textarea>`, `<select>` or text `<input>` found by given selector.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<input type="text" value="John Doe" id="username">
|
||||
|
||||
:getValue.js
|
||||
it('should demonstrate the getValue command', function () {
|
||||
var inputUser = $('#username');
|
||||
|
||||
var value = inputUser.getValue();
|
||||
console.log(value); // outputs: "John Doe"
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getValue
|
||||
* @param {String} selector input, textarea, or select element
|
||||
* @return {String} requested input value
|
||||
* @uses protocol/elements, protocol/elementIdAttribute
|
||||
* @type property
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let getValue = function (selector) {
|
||||
return this.elements(selector).then((res) => {
|
||||
/**
|
||||
* throw NoSuchElement error if no element was found
|
||||
*/
|
||||
if (!res.value || res.value.length === 0) {
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
let elementIdAttributeCommands = []
|
||||
for (let elem of res.value) {
|
||||
elementIdAttributeCommands.push(this.elementIdAttribute(elem.ELEMENT, 'value'))
|
||||
}
|
||||
|
||||
return this.unify(elementIdAttributeCommands, {
|
||||
extractValue: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default getValue
|
||||
46
static/js/ketcher2/node_modules/webdriverio/lib/commands/getViewportSize.js
generated
vendored
Normal file
46
static/js/ketcher2/node_modules/webdriverio/lib/commands/getViewportSize.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
*
|
||||
* Get viewport size of the current browser window. This command only works on desktop browser or in a mobile
|
||||
* environment with a webview enabled.
|
||||
*
|
||||
* <example>
|
||||
:getViewportSize.js
|
||||
it('should return the viewport size', function () {
|
||||
browser.url('http://webdriver.io');
|
||||
|
||||
var size = browser.getViewportSize()
|
||||
console.log(size); // outputs: {width: 1024, height: 768}
|
||||
|
||||
var width = browser.getViewportSize('width')
|
||||
console.log(size); // outputs: 1024
|
||||
|
||||
var height = browser.getViewportSize('height');
|
||||
console.log(height); // outputs: 768
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.getViewportSize
|
||||
* @param {String} property if "width" or "height" is set it returns only that property
|
||||
* @return {Object} viewport width and height of the browser
|
||||
* @uses protocol/execute
|
||||
* @type window
|
||||
*
|
||||
*/
|
||||
|
||||
import getViewportSizeHelper from '../scripts/getViewportSize'
|
||||
|
||||
let getViewportSize = function (prop) {
|
||||
return this.execute(getViewportSizeHelper).then((res) => {
|
||||
if (typeof prop === 'string' && prop.match(/(width|height)/)) {
|
||||
prop = 'screen' + prop.slice(0, 1).toUpperCase() + prop.slice(1)
|
||||
return res.value[prop]
|
||||
}
|
||||
|
||||
return {
|
||||
width: res.value.screenWidth || 0,
|
||||
height: res.value.screenHeight || 0
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default getViewportSize
|
||||
58
static/js/ketcher2/node_modules/webdriverio/lib/commands/hasFocus.js
generated
vendored
Normal file
58
static/js/ketcher2/node_modules/webdriverio/lib/commands/hasFocus.js
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
*
|
||||
* Return true or false if the selected DOM-element currently has focus. If the selector matches
|
||||
* multiple elements, it will return true if one of the elements has focus.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<input name="login" autofocus="" />
|
||||
|
||||
:hasFocus.js
|
||||
it('should detect the focus of an element', function () {
|
||||
browser.url('/');
|
||||
|
||||
var loginInput = $('[name="login"]');
|
||||
console.log(loginInput.hasFocus()); // outputs: false
|
||||
|
||||
loginInput.click();
|
||||
console.log(loginInput.hasFocus()); // outputs: true
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.hasFocus
|
||||
* @param {String} selector selector for element(s) to test for focus
|
||||
* @return {Boolean} true if one of the matching elements has focus
|
||||
* @uses protocol/execute protocol/elements
|
||||
* @type state
|
||||
*
|
||||
*/
|
||||
|
||||
import { RuntimeError } from '../utils/ErrorHandler'
|
||||
|
||||
let hasFocus = function (selector) {
|
||||
return this.unify(this.elements(selector).then((res) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!res.value || !res.value.length) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
return res.value
|
||||
}).then((elements) => {
|
||||
return this.execute(function (elemArray) {
|
||||
var focused = document.activeElement
|
||||
if (!focused) {
|
||||
return false
|
||||
}
|
||||
|
||||
return elemArray
|
||||
.filter((elem) => focused === elem)
|
||||
.length > 0
|
||||
}, elements)
|
||||
}), {
|
||||
extractValue: true
|
||||
})
|
||||
}
|
||||
|
||||
export default hasFocus
|
||||
28
static/js/ketcher2/node_modules/webdriverio/lib/commands/hold.js
generated
vendored
Normal file
28
static/js/ketcher2/node_modules/webdriverio/lib/commands/hold.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
*
|
||||
* Long press on an element using finger motion events. This command works only in a
|
||||
* mobile context.
|
||||
*
|
||||
* @alias browser.hold
|
||||
* @param {String} selector element to hold on
|
||||
* @uses protocol/element, protocol/touchLongClick
|
||||
* @type mobile
|
||||
*
|
||||
*/
|
||||
|
||||
import { RuntimeError } from '../utils/ErrorHandler'
|
||||
|
||||
let hold = function (selector) {
|
||||
return this.element(selector).then((res) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!res.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
return this.touchLongClick(res.value.ELEMENT)
|
||||
})
|
||||
}
|
||||
|
||||
export default hold
|
||||
54
static/js/ketcher2/node_modules/webdriverio/lib/commands/isEnabled.js
generated
vendored
Normal file
54
static/js/ketcher2/node_modules/webdriverio/lib/commands/isEnabled.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
*
|
||||
* Return true or false if the selected DOM-element found by given selector is enabled.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<input type="text" name="inputField" class="input1">
|
||||
<input type="text" name="inputField" class="input2" disabled>
|
||||
<input type="text" name="inputField" class="input3" disabled="disabled">
|
||||
|
||||
:isEnabled.js
|
||||
it('should detect if an element is enabled', function () {
|
||||
var isEnabled = browser.isEnabled('.input1');
|
||||
console.log(isEnabled); // outputs: true
|
||||
|
||||
var isEnabled2 = browser.isEnabled('.input2');
|
||||
console.log(isEnabled2); // outputs: false
|
||||
|
||||
var isEnabled3 = browser.isEnabled('.input3')
|
||||
console.log(isEnabled3); // outputs: false
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.isEnabled
|
||||
* @param {String} selector DOM-element
|
||||
* @return {Boolean|Boolean[]} true if element(s)* (is|are) enabled
|
||||
* @uses protocol/elements, protocol/elementIdEnabled
|
||||
* @type state
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let isEnabled = function (selector) {
|
||||
return this.elements(selector).then((res) => {
|
||||
/**
|
||||
* throw NoSuchElement error if no element was found
|
||||
*/
|
||||
if (!res.value || res.value.length === 0) {
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
let elementIdEnabledCommands = []
|
||||
for (let elem of res.value) {
|
||||
elementIdEnabledCommands.push(this.elementIdEnabled(elem.ELEMENT))
|
||||
}
|
||||
|
||||
return this.unify(elementIdEnabledCommands, {
|
||||
extractValue: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default isEnabled
|
||||
50
static/js/ketcher2/node_modules/webdriverio/lib/commands/isExisting.js
generated
vendored
Normal file
50
static/js/ketcher2/node_modules/webdriverio/lib/commands/isExisting.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
*
|
||||
* Returns true if at least one element is existing by given selector
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<div id="notDisplayed" style="display: none"></div>
|
||||
<div id="notVisible" style="visibility: hidden"></div>
|
||||
<div id="notInViewport" style="position:absolute; left: 9999999"></div>
|
||||
<div id="zeroOpacity" style="opacity: 0"></div>
|
||||
|
||||
:isExisting.js
|
||||
it('should detect if elements are existing', function () {
|
||||
var isExisting;
|
||||
isExisting = browser.isExisting('#someRandomNonExistingElement');
|
||||
console.log(isExisting); // outputs: false
|
||||
|
||||
isExisting = browser.isExisting('#notDisplayed');
|
||||
console.log(isExisting); // outputs: true
|
||||
|
||||
isExisting = browser.isExisting('#notVisible');
|
||||
console.log(isExisting); // outputs: true
|
||||
|
||||
isExisting = browser.isExisting('#notInViewport');
|
||||
console.log(isExisting); // outputs: true
|
||||
|
||||
isExisting = browser.isExisting('#zeroOpacity');
|
||||
console.log(isExisting); // outputs: true
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.isExisting
|
||||
* @param {String} selector DOM-element
|
||||
* @return {Boolean|Boolean[]} true if element(s)* [is|are] existing
|
||||
* @uses protocol/elements
|
||||
* @type state
|
||||
*
|
||||
*/
|
||||
|
||||
let isExisting = function (selector) {
|
||||
return this.elements(selector).then((res) => {
|
||||
if (Array.isArray(res.value) && res.value.length > 0) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
export default isExisting
|
||||
54
static/js/ketcher2/node_modules/webdriverio/lib/commands/isSelected.js
generated
vendored
Normal file
54
static/js/ketcher2/node_modules/webdriverio/lib/commands/isSelected.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
*
|
||||
* Return true or false if an `<option>` element, or an `<input>` element of type
|
||||
* checkbox or radio is currently selected found by given selector.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<select name="selectbox" id="selectbox">
|
||||
<option value="John Doe">John Doe</option>
|
||||
<option value="Layla Terry" selected="selected">Layla Terry</option>
|
||||
<option value="Bill Gilbert">Bill Gilbert"</option>
|
||||
</select>
|
||||
|
||||
:isSelected.js
|
||||
it('should detect if an element is selected', function () {
|
||||
var element = $('[value="Layla Terry"]');
|
||||
console.log(element.isSelected()); // outputs: true
|
||||
|
||||
browser.selectByValue('#selectbox', 'Bill Gilbert');
|
||||
console.log(element.isSelected()); // outputs: false
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.isSelected
|
||||
* @param {String} selector option element or input of type checkbox or radio
|
||||
* @return {Boolean|Boolean[]} true if element is selected
|
||||
* @uses protocol/elements, protocol/elementIdSelected
|
||||
* @type state
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let isSelected = function (selector) {
|
||||
return this.elements(selector).then((res) => {
|
||||
/**
|
||||
* throw NoSuchElement error if no element was found
|
||||
*/
|
||||
if (!res.value || res.value.length === 0) {
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
let elementIdSelectedCommands = []
|
||||
for (let elem of res.value) {
|
||||
elementIdSelectedCommands.push(this.elementIdSelected(elem.ELEMENT))
|
||||
}
|
||||
|
||||
return this.unify(elementIdSelectedCommands, {
|
||||
extractValue: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default isSelected
|
||||
59
static/js/ketcher2/node_modules/webdriverio/lib/commands/isVisible.js
generated
vendored
Normal file
59
static/js/ketcher2/node_modules/webdriverio/lib/commands/isVisible.js
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
*
|
||||
* Return true if the selected DOM-element found by given selector is visible. Returns an array if multiple DOM-elements are found for the given selector.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<div id="notDisplayed" style="display: none"></div>
|
||||
<div id="notVisible" style="visibility: hidden"></div>
|
||||
<div id="notInViewport" style="position:absolute; left: 9999999"></div>
|
||||
<div id="zeroOpacity" style="opacity: 0"></div>
|
||||
|
||||
:isVisible.js
|
||||
it('should detect if an element is visible', function () {
|
||||
var isVisible = browser.isVisible('#notDisplayed');
|
||||
console.log(isVisible); // outputs: false
|
||||
|
||||
isVisible = browser.isVisible('#notVisible');
|
||||
console.log(isVisible); // outputs: false
|
||||
|
||||
isVisible = browser.isVisible('#notExisting');
|
||||
console.log(isVisible); // outputs: false
|
||||
|
||||
isVisible = browser.isVisible('#notInViewport');
|
||||
console.log(isVisible); // outputs: true
|
||||
|
||||
isVisible = browser.isVisible('#zeroOpacity');
|
||||
console.log(isVisible); // outputs: true
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.isVisible
|
||||
* @param {String} selector DOM-element
|
||||
* @return {Boolean|Boolean[]} true if element(s)* [is|are] visible
|
||||
* @uses protocol/elements, protocol/elementIdDisplayed
|
||||
* @type state
|
||||
*
|
||||
*/
|
||||
|
||||
let isVisible = function (selector) {
|
||||
return this.elements(selector).then((res) => {
|
||||
/**
|
||||
* if element does not exist it is automatically not visible ;-)
|
||||
*/
|
||||
if (!res.value || res.value.length === 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
let elementIdDisplayedCommands = []
|
||||
for (let elem of res.value) {
|
||||
elementIdDisplayedCommands.push(this.elementIdDisplayed(elem.ELEMENT))
|
||||
}
|
||||
|
||||
return this.unify(elementIdDisplayedCommands, {
|
||||
extractValue: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default isVisible
|
||||
59
static/js/ketcher2/node_modules/webdriverio/lib/commands/isVisibleWithinViewport.js
generated
vendored
Normal file
59
static/js/ketcher2/node_modules/webdriverio/lib/commands/isVisibleWithinViewport.js
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
*
|
||||
* Return true if the selected DOM-element found by given selector is visible and within the viewport.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<div id="notDisplayed" style="display: none"></div>
|
||||
<div id="notVisible" style="visibility: hidden"></div>
|
||||
<div id="notInViewport" style="position:absolute; left: 9999999"></div>
|
||||
<div id="zeroOpacity" style="opacity: 0"></div>
|
||||
|
||||
:isVisibleWithinViewport.js
|
||||
:isVisible.js
|
||||
it('should detect if an element is visible', function () {
|
||||
var isVisibleWithinViewport = browser.isVisibleWithinViewport('#notDisplayed');
|
||||
console.log(isVisibleWithinViewport); // outputs: false
|
||||
|
||||
isVisibleWithinViewport = browser.isVisibleWithinViewport('#notVisible');
|
||||
console.log(isVisibleWithinViewport); // outputs: false
|
||||
|
||||
isVisibleWithinViewport = browser.isVisibleWithinViewport('#notExisting');
|
||||
console.log(isVisibleWithinViewport); // outputs: false
|
||||
|
||||
isVisibleWithinViewport = browser.isVisibleWithinViewport('#notInViewport');
|
||||
console.log(isVisibleWithinViewport); // outputs: false
|
||||
|
||||
isVisibleWithinViewport = browser.isVisibleWithinViewport('#zeroOpacity');
|
||||
console.log(isVisibleWithinViewport); // outputs: false
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.isVisibleWithinViewport
|
||||
* @param {String} selector DOM-element
|
||||
* @return {Boolean|Boolean[]} true if element(s)* [is|are] visible
|
||||
* @uses protocol/selectorExecute, protocol/timeoutsAsyncScript
|
||||
* @type state
|
||||
*
|
||||
*/
|
||||
|
||||
import isVisibleWithinViewportFunc from '../scripts/isWithinViewport'
|
||||
|
||||
module.exports = function isVisibleWithinViewport (selector) {
|
||||
return this.selectorExecute(selector, isVisibleWithinViewportFunc).then((res) => {
|
||||
if (Array.isArray(res) && res.length === 1) {
|
||||
return res[0]
|
||||
}
|
||||
|
||||
return res
|
||||
}, (err) => {
|
||||
/**
|
||||
* if element does not exist it is automatically not visible :-)
|
||||
*/
|
||||
if (err.message.indexOf('NoSuchElement') > -1) {
|
||||
return true
|
||||
}
|
||||
|
||||
throw err
|
||||
})
|
||||
}
|
||||
21
static/js/ketcher2/node_modules/webdriverio/lib/commands/leftClick.js
generated
vendored
Executable file
21
static/js/ketcher2/node_modules/webdriverio/lib/commands/leftClick.js
generated
vendored
Executable file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
*
|
||||
* Apply left click on an element. If selector is not provided, click on the last
|
||||
* moved-to location.
|
||||
*
|
||||
* @alias browser.leftClick
|
||||
* @param {String} selector element to click on
|
||||
* @param {Number} xoffset X offset to move to, relative to the top-left corner of the element.
|
||||
* @param {Number} yoffset Y offset to move to, relative to the top-left corner of the element.
|
||||
* @uses protocol/element, protocol/buttonPress
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
import handleMouseButtonCommand from '../helpers/handleMouseButtonCommand'
|
||||
|
||||
let leftClick = function (selector, xoffset, yoffset) {
|
||||
return handleMouseButtonCommand.call(this, selector, 'left', xoffset, yoffset)
|
||||
}
|
||||
|
||||
export default leftClick
|
||||
21
static/js/ketcher2/node_modules/webdriverio/lib/commands/middleClick.js
generated
vendored
Executable file
21
static/js/ketcher2/node_modules/webdriverio/lib/commands/middleClick.js
generated
vendored
Executable file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
*
|
||||
* Apply middle click on an element. If selector is not provided, click on the last
|
||||
* moved-to location.
|
||||
*
|
||||
* @alias browser.middleClick
|
||||
* @param {String} selector element to click on
|
||||
* @param {Number} xoffset X offset to move to, relative to the top-left corner of the element.
|
||||
* @param {Number} yoffset Y offset to move to, relative to the top-left corner of the element.
|
||||
* @uses protocol/element, protocol/buttonPress
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
import handleMouseButtonCommand from '../helpers/handleMouseButtonCommand'
|
||||
|
||||
let middleClick = function (selector, xoffset, yoffset) {
|
||||
return handleMouseButtonCommand.call(this, selector, 'middle', xoffset, yoffset)
|
||||
}
|
||||
|
||||
export default middleClick
|
||||
66
static/js/ketcher2/node_modules/webdriverio/lib/commands/moveToObject.js
generated
vendored
Normal file
66
static/js/ketcher2/node_modules/webdriverio/lib/commands/moveToObject.js
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
*
|
||||
* Move the mouse by an offset of the specificed element. If an element is provided but no
|
||||
* offset, the mouse will be moved to the center of the element. If the element is not
|
||||
* visible, it will be scrolled into view.
|
||||
*
|
||||
* @alias browser.moveToObject
|
||||
* @param {String} selector element to move to
|
||||
* @param {Number} xoffset X offset to move to, relative to the top-left corner of the element. If not specified, the mouse will move to the middle of the element.
|
||||
* @param {Number} yoffset Y offset to move to, relative to the top-left corner of the element. If not specified, the mouse will move to the middle of the element.
|
||||
* @uses protocol/element, protocol/elementIdLocation
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
import { RuntimeError } from '../utils/ErrorHandler'
|
||||
|
||||
let moveToObject = function (selector, xoffset, yoffset) {
|
||||
/**
|
||||
* check for offset params
|
||||
*/
|
||||
var hasOffsetParams = true
|
||||
if (typeof xoffset !== 'number' && typeof yoffset !== 'number') {
|
||||
hasOffsetParams = false
|
||||
}
|
||||
|
||||
if (this.isMobile) {
|
||||
return this.element(selector).then((res) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!res.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
return this.elementIdSize(res.value.ELEMENT).then((size) =>
|
||||
this.elementIdLocation(res.value.ELEMENT).then((location) => {
|
||||
return { size, location }
|
||||
})
|
||||
)
|
||||
}).then((res) => {
|
||||
let x = res.location.value.x + (res.size.value.width / 2)
|
||||
let y = res.location.value.y + (res.size.value.height / 2)
|
||||
|
||||
if (hasOffsetParams) {
|
||||
x = res.location.value.x + xoffset
|
||||
y = res.location.value.y + yoffset
|
||||
}
|
||||
|
||||
return this.touchMove(x, y)
|
||||
})
|
||||
}
|
||||
|
||||
return this.element(selector).then((res) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!res.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
return this.moveTo(res.value.ELEMENT, xoffset, yoffset)
|
||||
})
|
||||
}
|
||||
|
||||
export default moveToObject
|
||||
53
static/js/ketcher2/node_modules/webdriverio/lib/commands/newWindow.js
generated
vendored
Normal file
53
static/js/ketcher2/node_modules/webdriverio/lib/commands/newWindow.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
*
|
||||
* Open new window in browser. This command is the equivalent function to `window.open()`. This command does not
|
||||
* work in mobile environments.
|
||||
*
|
||||
* __Note:__ When calling this command you automatically switch to the new window.
|
||||
*
|
||||
* <example>
|
||||
:newWindowSync.js
|
||||
it('should open a new tab', function () {
|
||||
browser.url('http://google.com')
|
||||
console.log(browser.getTitle()); // outputs: "Google"
|
||||
|
||||
browser.newWindow('http://webdriver.io', 'WebdriverIO window', 'width=420,height=230,resizable,scrollbars=yes,status=1')
|
||||
console.log(browser.getTitle()); // outputs: "WebdriverIO - WebDriver bindings for Node.js"
|
||||
|
||||
browser.close()
|
||||
console.log(browser.getTitle()); // outputs: "Google"
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.newWindow
|
||||
* @param {String} url website URL to open
|
||||
* @param {String} windowName name of the new window
|
||||
* @param {String} windowFeatures features of opened window (e.g. size, position, scrollbars, etc.)
|
||||
* @uses protocol/execute, window/getTabIds, window/switchTab
|
||||
* @type window
|
||||
*
|
||||
*/
|
||||
|
||||
import newWindowHelper from '../scripts/newWindow'
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let newWindow = function (url, windowName = '', windowFeatures = '') {
|
||||
/*!
|
||||
* parameter check
|
||||
*/
|
||||
if (typeof url !== 'string' || typeof windowName !== 'string' || typeof windowFeatures !== 'string') {
|
||||
throw new CommandError('number or type of arguments don\'t agree with newWindow command')
|
||||
}
|
||||
|
||||
/*!
|
||||
* mobile check
|
||||
*/
|
||||
if (this.isMobile) {
|
||||
throw new CommandError('newWindow command is not supported on mobile platforms')
|
||||
}
|
||||
|
||||
return this.execute(newWindowHelper, url, windowName, windowFeatures).getTabIds().then(
|
||||
(tabs) => this.switchTab(tabs[tabs.length - 1]))
|
||||
}
|
||||
|
||||
export default newWindow
|
||||
27
static/js/ketcher2/node_modules/webdriverio/lib/commands/pause.js
generated
vendored
Normal file
27
static/js/ketcher2/node_modules/webdriverio/lib/commands/pause.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
*
|
||||
* Pauses execution for a specific amount of time. It is recommended to not use this command to wait for an
|
||||
* element to show up. In order to avoid flaky test results it is better to use commands like
|
||||
* [`waitforExist`](/api/utility/waitForExist.html) or other waitFor* commands.
|
||||
*
|
||||
* <example>
|
||||
:pause.js
|
||||
it('should pause the execution', function () {
|
||||
var starttime = new Date().getTime();
|
||||
browser.pause(3000);
|
||||
var endtime = new Date().getTime();
|
||||
console.log(endtime - starttime); // outputs: 3000
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.pause
|
||||
* @param {Number} milliseconds time in ms
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
let pause = function (milliseconds = 1000) {
|
||||
return new Promise((resolve) => setTimeout(resolve, milliseconds))
|
||||
}
|
||||
|
||||
export default pause
|
||||
17
static/js/ketcher2/node_modules/webdriverio/lib/commands/release.js
generated
vendored
Normal file
17
static/js/ketcher2/node_modules/webdriverio/lib/commands/release.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
*
|
||||
* Release touch sequence on specific element.
|
||||
*
|
||||
* @alias browser.release
|
||||
* @param {String} selector element to release on
|
||||
* @uses property/getLocation, protocol/touchUp
|
||||
* @type mobile
|
||||
*
|
||||
*/
|
||||
|
||||
let release = function (selector) {
|
||||
return this.getLocation(selector).then(
|
||||
(res) => this.touchUp(res.x, res.y))
|
||||
}
|
||||
|
||||
export default release
|
||||
41
static/js/ketcher2/node_modules/webdriverio/lib/commands/reload.js
generated
vendored
Normal file
41
static/js/ketcher2/node_modules/webdriverio/lib/commands/reload.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
*
|
||||
* Creates a new Selenium session with your current capabilities. This is useful if you
|
||||
* test highly stateful application where you need to clean the browser session between
|
||||
* the tests in your spec file to avoid creating hundreds of single test files with WDIO.
|
||||
* Be careful though, this command affects your test time tremendously since spawning
|
||||
* new Selenium sessions is very time consuming especially when using cloud services.
|
||||
*
|
||||
* <example>
|
||||
:reloadSync.js
|
||||
it('should reload my session', function () {
|
||||
console.log(browser.sessionId); // outputs: e042b3f3cd5a479da4e171825e96e655
|
||||
browser.reload();
|
||||
console.log(browser.sessionId); // outputs: 9a0d9bf9d4864160aa982c50cf18a573
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.reload
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
let reload = function () {
|
||||
const oldSessionId = this.requestHandler.sessionID
|
||||
|
||||
return this.end().init().then((res) => {
|
||||
const newSessionId = this.requestHandler.sessionID
|
||||
|
||||
if (!Array.isArray(this.options.onReload)) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
return Promise.all(this.options.onReload.map(
|
||||
(hook) => hook(oldSessionId, newSessionId)
|
||||
))
|
||||
}).catch((e) => {
|
||||
console.log(`Error in onReload hook: "${e.stack}"`)
|
||||
})
|
||||
}
|
||||
|
||||
export default reload
|
||||
21
static/js/ketcher2/node_modules/webdriverio/lib/commands/rightClick.js
generated
vendored
Executable file
21
static/js/ketcher2/node_modules/webdriverio/lib/commands/rightClick.js
generated
vendored
Executable file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
*
|
||||
* Apply right click on an element. If selector is not provided, click on the last
|
||||
* moved-to location.
|
||||
*
|
||||
* @alias browser.rightClick
|
||||
* @param {String} selector element to click on
|
||||
* @param {Number} xoffset X offset to move to, relative to the top-left corner of the element.
|
||||
* @param {Number} yoffset Y offset to move to, relative to the top-left corner of the element.
|
||||
* @uses protocol/element, protocol/buttonPress
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
import handleMouseButtonCommand from '../helpers/handleMouseButtonCommand'
|
||||
|
||||
let rightClick = function (selector, xoffset, yoffset) {
|
||||
return handleMouseButtonCommand.call(this, selector, 'right', xoffset, yoffset)
|
||||
}
|
||||
|
||||
export default rightClick
|
||||
50
static/js/ketcher2/node_modules/webdriverio/lib/commands/saveScreenshot.js
generated
vendored
Normal file
50
static/js/ketcher2/node_modules/webdriverio/lib/commands/saveScreenshot.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
|
||||
/**
|
||||
*
|
||||
* Save a screenshot as a base64 encoded PNG with the current state of the browser. Be aware that some Selenium driver
|
||||
* are taking screenshots of the whole document (e.g. phantomjs) and others only of the current viewport. If you want
|
||||
* to always be sure that the screenshot has the size of the whole document, use [wdio-screenshot](https://www.npmjs.com/package/wdio-screenshot)
|
||||
* to enhance this command with that functionality.
|
||||
*
|
||||
* This command also doesn't support the [element screenshot](https://w3c.github.io/webdriver/webdriver-spec.html#take-element-screenshot)
|
||||
* feature yet as it isn't supported by most of the drivers. However the protocol command for it is available
|
||||
* to use (see [elementIdScreenshot](http://webdriver.io/api/protocol/elementIdScreenshot.html)).
|
||||
*
|
||||
* <example>
|
||||
:saveScreenshot.js
|
||||
it('should save a screenshot of the browser view', function () {
|
||||
// receive screenshot as Buffer
|
||||
var screenshot = browser.saveScreenshot(); // returns base64 string buffer
|
||||
fs.writeFileSync('./myShort.png', screenshot)
|
||||
|
||||
// save screenshot to file and receive as Buffer
|
||||
screenshot = browser.saveScreenshot('./snapshot.png');
|
||||
|
||||
// save screenshot to file
|
||||
browser.saveScreenshot('./snapshot.png');
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.saveScreenshot
|
||||
* @param {Function|String=} filename path to the generated image (relative to the execution directory)
|
||||
* @uses protocol/screenshot
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
import fs from 'fs'
|
||||
import { Buffer } from 'safe-buffer'
|
||||
|
||||
export default function saveScreenshot (filename) {
|
||||
return this.screenshot().then((res) => {
|
||||
this.emit('screenshot', {data: res.value, filename})
|
||||
|
||||
let screenshot = new Buffer(res.value, 'base64')
|
||||
|
||||
if (typeof filename === 'string') {
|
||||
fs.writeFileSync(filename, screenshot)
|
||||
}
|
||||
|
||||
return screenshot
|
||||
})
|
||||
}
|
||||
90
static/js/ketcher2/node_modules/webdriverio/lib/commands/scroll.js
generated
vendored
Normal file
90
static/js/ketcher2/node_modules/webdriverio/lib/commands/scroll.js
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
/**
|
||||
*
|
||||
* Scroll to a specific element. You can also append/pass two offset values as parameter
|
||||
* to scroll to a specific position.
|
||||
*
|
||||
* <example>
|
||||
:scroll.js
|
||||
it('should demonstrate the scroll command', function () {
|
||||
var elem = $('#myElement');
|
||||
|
||||
// scroll to specific element
|
||||
elem.scroll();
|
||||
|
||||
// scroll to specific element with offset
|
||||
// scroll offset will be added to elements position
|
||||
elem.scroll(100, 100);
|
||||
|
||||
// scroll to specific x and y position
|
||||
browser.scroll(0, 250);
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.scroll
|
||||
* @param {String=} selector element to scroll to
|
||||
* @param {Number=} xoffset x offset to scroll to
|
||||
* @param {Number=} yoffset y offset to scroll to
|
||||
* @uses protocol/element, protocol/elementIdLocation, protocol/touchScroll, protocol/execute
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
import { RuntimeError } from '../utils/ErrorHandler'
|
||||
import scrollHelper from '../scripts/scroll'
|
||||
|
||||
let scroll = function (selector, xoffset, yoffset) {
|
||||
/**
|
||||
* we can't use default values for function parameter here because this would
|
||||
* break the ability to chain the command with an element if an offset is used
|
||||
*/
|
||||
xoffset = typeof xoffset === 'number' ? xoffset : 0
|
||||
yoffset = typeof yoffset === 'number' ? yoffset : 0
|
||||
|
||||
if (typeof selector === 'number' && typeof xoffset === 'number') {
|
||||
yoffset = xoffset
|
||||
xoffset = selector
|
||||
selector = null
|
||||
}
|
||||
|
||||
if (this.isMobile) {
|
||||
var queue = Promise.resolve()
|
||||
|
||||
if (selector) {
|
||||
queue = this.element(selector)
|
||||
}
|
||||
|
||||
return queue.then((res) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (res && !res.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
if (typeof res !== 'undefined') {
|
||||
selector = res.value.ELEMENT
|
||||
}
|
||||
|
||||
return this.touchScroll(selector, xoffset, yoffset)
|
||||
})
|
||||
}
|
||||
|
||||
if (selector) {
|
||||
return this.element(selector).then((res) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!res.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
return this.elementIdLocation(res.value.ELEMENT)
|
||||
}).then((location) =>
|
||||
this.execute(scrollHelper, location.value.x + xoffset, location.value.y + yoffset)
|
||||
)
|
||||
}
|
||||
|
||||
return this.execute(scrollHelper, xoffset, yoffset)
|
||||
}
|
||||
|
||||
export default scroll
|
||||
81
static/js/ketcher2/node_modules/webdriverio/lib/commands/selectByAttribute.js
generated
vendored
Normal file
81
static/js/ketcher2/node_modules/webdriverio/lib/commands/selectByAttribute.js
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
/**
|
||||
*
|
||||
* Select option with a specific value.
|
||||
*
|
||||
* <example>
|
||||
:example.html
|
||||
<select id="selectbox">
|
||||
<option value="someValue0">uno</option>
|
||||
<option value="someValue1">dos</option>
|
||||
<option value="someValue2">tres</option>
|
||||
<option value="someValue3">cuatro</option>
|
||||
<option value="someValue4">cinco</option>
|
||||
<option name="someName5" value="someValue5">seis</option>
|
||||
</select>
|
||||
|
||||
:selectByAttribute.js
|
||||
it('should demonstrate the selectByAttribute command', function () {
|
||||
var selectBox = $('#selectbox');
|
||||
|
||||
var value = selectBox.getValue();
|
||||
console.log(value); // returns "someValue0"
|
||||
|
||||
selectBox.selectByAttribute('value', 'someValue3');
|
||||
console.log(selectBox.getValue()); // returns "someValue3"
|
||||
|
||||
selectBox.selectByAttribute('name', 'someName5');
|
||||
console.log(selectBox.getValue()); // returns "someValue5"
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.selectByAttribute
|
||||
* @param {String} selector select element that contains the options
|
||||
* @param {String} attribute attribute of option element to get selected
|
||||
* @param {String} value value of option element to get selected
|
||||
* @uses protocol/element, protocol/elementIdClick, protocol/elementIdElement
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
import { RuntimeError } from '../utils/ErrorHandler'
|
||||
|
||||
let selectByAttribute = function (selector, attribute, value) {
|
||||
/**
|
||||
* convert value into string
|
||||
*/
|
||||
if (typeof value === 'number') {
|
||||
value = value.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* get options element by xpath
|
||||
*/
|
||||
return this.element(selector).then((res) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!res.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
/**
|
||||
* find option elem using xpath
|
||||
*/
|
||||
var normalized = `[normalize-space(@${attribute.trim()}) = "${value.trim()}"]`
|
||||
return this.elementIdElement(res.value.ELEMENT, `./option${normalized}|./optgroup/option${normalized}`)
|
||||
}).then((res) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!res.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
/**
|
||||
* select option
|
||||
*/
|
||||
return this.elementIdClick(res.value.ELEMENT)
|
||||
})
|
||||
}
|
||||
|
||||
export default selectByAttribute
|
||||
65
static/js/ketcher2/node_modules/webdriverio/lib/commands/selectByIndex.js
generated
vendored
Normal file
65
static/js/ketcher2/node_modules/webdriverio/lib/commands/selectByIndex.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
*
|
||||
* Select option with a specific index.
|
||||
*
|
||||
* <example>
|
||||
:example.html
|
||||
<select id="selectbox">
|
||||
<option value="someValue0">uno</option>
|
||||
<option value="someValue1">dos</option>
|
||||
<option value="someValue2">tres</option>
|
||||
<option value="someValue3">cuatro</option>
|
||||
<option value="someValue4">cinco</option>
|
||||
<option value="someValue5">seis</option>
|
||||
</select>
|
||||
|
||||
:selectByIndex.js
|
||||
it('should demonstrate the selectByIndex command', function () {
|
||||
var selectBox = $('#selectbox');
|
||||
console.log(selectBox.getValue()); // returns "someValue0"
|
||||
|
||||
selectBox.selectByIndex(4);
|
||||
console.log(selectBox.getValue()); // returns "someValue4"
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.selectByIndex
|
||||
* @param {String} selector select element that contains the options
|
||||
* @param {Number} index option index
|
||||
* @uses protocol/element, protocol/elementIdElements, protocol/elementIdClick
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError, RuntimeError } from '../utils/ErrorHandler'
|
||||
|
||||
let selectByIndex = function (selector, index) {
|
||||
/*!
|
||||
* negative index check
|
||||
*/
|
||||
if (index < 0) {
|
||||
throw new CommandError('index needs to be 0 or any other positive number')
|
||||
}
|
||||
|
||||
return this.element(selector).then((element) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!element.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
return this.elementIdElements(element.value.ELEMENT, '<option>')
|
||||
}).then((elements) => {
|
||||
if (elements.value.length === 0) {
|
||||
throw new CommandError(`select element (${selector}) doesn't contain any option element`)
|
||||
}
|
||||
if (elements.value.length - 1 < index) {
|
||||
throw new CommandError(`option with index "${index}" not found. Select element (${selector}) only contains ${elements.value.length} option elements`)
|
||||
}
|
||||
|
||||
return this.elementIdClick(elements.value[index].ELEMENT)
|
||||
})
|
||||
}
|
||||
|
||||
export default selectByIndex
|
||||
38
static/js/ketcher2/node_modules/webdriverio/lib/commands/selectByValue.js
generated
vendored
Normal file
38
static/js/ketcher2/node_modules/webdriverio/lib/commands/selectByValue.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
*
|
||||
* Select option with a specific value.
|
||||
*
|
||||
* <example>
|
||||
:example.html
|
||||
<select id="selectbox">
|
||||
<option value="someValue0">uno</option>
|
||||
<option value="someValue1">dos</option>
|
||||
<option value="someValue2">tres</option>
|
||||
<option value="someValue3">cuatro</option>
|
||||
<option value="someValue4">cinco</option>
|
||||
<option value="someValue5">seis</option>
|
||||
</select>
|
||||
|
||||
:selectByValue.js
|
||||
it('should demonstrate the selectByValue command', function () {
|
||||
var selectBox = $('#selectbox');
|
||||
console.log(selectBox.getValue()); // returns "someValue0"
|
||||
|
||||
selectBox.selectByValue('someValue3');
|
||||
console.log(selectBox.getValue()); // returns "someValue3"
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.selectByValue
|
||||
* @param {String} selector select element that contains the options
|
||||
* @param {String} value value of option element to get selected
|
||||
* @uses protocol/element, protocol/elementIdClick, protocol/elementIdElement
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
let selectByValue = function (selector, value) {
|
||||
return this.selectByAttribute(selector, 'value', value)
|
||||
}
|
||||
|
||||
export default selectByValue
|
||||
74
static/js/ketcher2/node_modules/webdriverio/lib/commands/selectByVisibleText.js
generated
vendored
Normal file
74
static/js/ketcher2/node_modules/webdriverio/lib/commands/selectByVisibleText.js
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
/**
|
||||
*
|
||||
* Select option which's displayed text matches the argument.
|
||||
*
|
||||
* <example>
|
||||
:example.html
|
||||
<select id="selectbox">
|
||||
<option value="someValue0">uno</option>
|
||||
<option value="someValue1">dos</option>
|
||||
<option value="someValue2">tres</option>
|
||||
<option value="someValue3">cuatro</option>
|
||||
<option value="someValue4">cinco</option>
|
||||
<option value="someValue5">seis</option>
|
||||
</select>
|
||||
|
||||
:selectByVisibleText.js
|
||||
it('demonstrate the selectByVisibleText command', function () {
|
||||
var selectBox = $('#selectbox');
|
||||
console.log(selectBox.getText('option:checked')); // returns "uno"
|
||||
|
||||
selectBox.selectByVisibleText('cuatro');
|
||||
console.log(selectBox.getText('option:checked')); // returns "cuatro"
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.selectByVisibleText
|
||||
* @param {String} selector select element that contains the options
|
||||
* @param {String} text text of option element to get selected
|
||||
* @uses protocol/element, protocol/elementIdClick, protocol/elementIdElement
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
import { RuntimeError } from '../utils/ErrorHandler'
|
||||
|
||||
let selectByVisibleText = function (selector, text) {
|
||||
/**
|
||||
* get select element
|
||||
*/
|
||||
return this.element(selector).then((res) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!res.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
/**
|
||||
* find option elem using xpath
|
||||
*/
|
||||
let formatted = `"${text.trim()}"`
|
||||
|
||||
if (/"/.test(text)) {
|
||||
formatted = 'concat("' + text.trim().split('"').join('", \'"\', "') + '")' // escape quotes
|
||||
}
|
||||
|
||||
var normalized = `[normalize-space(.) = ${formatted}]`
|
||||
return this.elementIdElement(res.value.ELEMENT, `./option${normalized}|./optgroup/option${normalized}`)
|
||||
}).then((res) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!res.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
/**
|
||||
* select option
|
||||
*/
|
||||
return this.elementIdClick(res.value.ELEMENT)
|
||||
})
|
||||
}
|
||||
|
||||
export default selectByVisibleText
|
||||
90
static/js/ketcher2/node_modules/webdriverio/lib/commands/selectorExecute.js
generated
vendored
Normal file
90
static/js/ketcher2/node_modules/webdriverio/lib/commands/selectorExecute.js
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
/**
|
||||
* Works just like execute, only you can use selectors to pass html elements to
|
||||
* the function you wish to execute in the browser.
|
||||
*
|
||||
* The function fn will receive every resolved selector as an array of html elements,
|
||||
* even if there is only one result, or no result.
|
||||
* These arrays are the first arguments the function fn receives.
|
||||
* If you pass an array of selectors, the resulting html element arrays are returned in the same order.
|
||||
*
|
||||
* All arguments you append after function fn are added as the arguments after the html arrays.
|
||||
* You can use any JSON value or a function as such an argument.
|
||||
*
|
||||
* <example>
|
||||
:selectorExecute.js
|
||||
it('it inject JavaScript to the page', function () {
|
||||
var divCount = browser.selectorExecute("//div", function(divs, message) {
|
||||
return divs.length + message;
|
||||
}, " divs on the page");
|
||||
console.log(divCount); // returns, for example, "68 divs on the page"
|
||||
|
||||
var divLinkCount = browser.selectorExecute(["//div", "=Read Post"], function(divs, links) {
|
||||
var message = 'There are ';
|
||||
|
||||
message += divs.length + ' divs on the page';
|
||||
message += ' and ';
|
||||
message += links.length + ' links with an link text "' + links[0].text + '"';
|
||||
|
||||
return message;
|
||||
});
|
||||
console.log(divLinkCount); // returns, for example, "There are 68 divs on the page and 42 links with an link text 'Read Post'"
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.selectorExecute
|
||||
* @param {String|Array.<String>} selectors single selector or array of selectors
|
||||
* @param {Function} script function to get executed in the browser
|
||||
* @param {...*} [argument1,...,argumentN] arguments added to fn. Can be any JSON value or function
|
||||
* @uses protocol/execute
|
||||
* @type action
|
||||
*/
|
||||
|
||||
import ensureClientSideSelectorSupport from '../helpers/ensureClientSideSelectorSupport'
|
||||
import createSelectorScript from '../scripts/createSelectorScript'
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let selectorExecute = function (selector, script, ...args) {
|
||||
/**
|
||||
* if selectorExecute gets executed with element as first citizen like
|
||||
*
|
||||
* ```js
|
||||
* var elem = $('#elem');
|
||||
* elem.selectorExecute(function () {...}, some, args);
|
||||
* ```
|
||||
*/
|
||||
if (typeof selector === 'function' && this.lastResult && typeof this.lastResult.selector === 'string') {
|
||||
args.unshift(script)
|
||||
script = selector
|
||||
selector = [this.lastResult.selector]
|
||||
|
||||
/**
|
||||
* if selectorExecute gets executed by getHTML
|
||||
*/
|
||||
} else if (selector === null) {
|
||||
selector = [this.lastResult.selector]
|
||||
}
|
||||
|
||||
if (typeof selector === 'string') {
|
||||
selector = [selector]
|
||||
}
|
||||
|
||||
if (!Array.isArray(selector)) {
|
||||
throw new CommandError('Argument \'selector\' must be string or array of strings.')
|
||||
}
|
||||
if (!/string|function/.test(typeof script)) {
|
||||
throw new CommandError('Argument \'script\' must be a function or string.')
|
||||
}
|
||||
|
||||
let fullScript = createSelectorScript.call(this, script, selector, args)
|
||||
return ensureClientSideSelectorSupport.call(this).execute(fullScript).then((res) => {
|
||||
var result = res && res.value
|
||||
|
||||
if (result && result.message === 'NoSuchElement') {
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
export default selectorExecute
|
||||
89
static/js/ketcher2/node_modules/webdriverio/lib/commands/selectorExecuteAsync.js
generated
vendored
Normal file
89
static/js/ketcher2/node_modules/webdriverio/lib/commands/selectorExecuteAsync.js
generated
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* Works just like execute, only you can use Selenium selector strategies to pass html elements to
|
||||
* the asynchronous function you wish to execute in the browser.
|
||||
*
|
||||
* The asynchronous function fn will receive every resolved selector as an array of html elements,
|
||||
* even if there is only one result, or no result.
|
||||
* These arrays are the first arguments the function fn receives.
|
||||
* If you pass an array of selectors, the resulting html element arrays are returned in the same order.
|
||||
*
|
||||
* All arguments you append after function fn are added as the arguments after the html arrays.
|
||||
* You can use any JSON value or a function as such an argument.
|
||||
*
|
||||
* <example>
|
||||
:selectorExecuteAsync.js
|
||||
it('should be able to inject JavaScript into the page that can be execute asynchronously', function () {
|
||||
var divCount = browser.selectorExecuteAsync("//div", function(divs, message, callback) {
|
||||
callback(divs.length + message);
|
||||
}, " divs on the page")
|
||||
console.log(divCount); // returns, for example, "68 divs on the page"
|
||||
|
||||
var divLinkCount = browser.selectorExecuteAsync(["//div", "=Read Post"], function(divs, links, callback) {
|
||||
var message = 'There are ';
|
||||
|
||||
message += divs.length + ' divs on the page';
|
||||
message += ' and ';
|
||||
message += links.length + ' links with an link text "' + links[0].text + '"';
|
||||
|
||||
callback(message);
|
||||
})
|
||||
console.log(divLinkCount); // returns, for example, "There are 68 divs on the page and 42 links with an link text 'Read Post'"
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.selectorExecuteAsync
|
||||
* @param {String|Array.<String>} selectors single selector or array of selectors
|
||||
* @param {Function} script asynchronous function to get executed in the browser
|
||||
* @param {...*} [argument1,...,argumentN] arguments added to fn. Can be any JSON value or function
|
||||
* @uses protocol/execute
|
||||
* @type action
|
||||
*/
|
||||
|
||||
import ensureClientSideSelectorSupport from '../helpers/ensureClientSideSelectorSupport'
|
||||
import createSelectorScript from '../scripts/createSelectorScript'
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let selectorExecuteAsync = function (selector, script, ...args) {
|
||||
/**
|
||||
* if selectorExecuteAsync gets executed with element as first citizen like
|
||||
*
|
||||
* ```js
|
||||
* var elem = $('#elem');
|
||||
* elem.selectorExecuteAsync(function () {...}, some, args);
|
||||
* ```
|
||||
*/
|
||||
if (typeof selector === 'function' && this.lastResult && typeof this.lastResult.selector === 'string') {
|
||||
args.unshift(script)
|
||||
script = selector
|
||||
selector = [this.lastResult.selector]
|
||||
|
||||
/**
|
||||
* if selectorExecuteAsync gets executed by getHTML
|
||||
*/
|
||||
} else if (selector === null) {
|
||||
selector = [this.lastResult.selector]
|
||||
}
|
||||
|
||||
if (typeof selector === 'string') {
|
||||
selector = [selector]
|
||||
}
|
||||
if (!Array.isArray(selector)) {
|
||||
throw new CommandError('Argument \'selector\' must be string or array of strings.')
|
||||
}
|
||||
if (!/string|function/.test(typeof script)) {
|
||||
throw new CommandError('Argument \'script\' must be a function or string.')
|
||||
}
|
||||
|
||||
let fullScript = createSelectorScript.call(this, script, selector, args)
|
||||
return ensureClientSideSelectorSupport.call(this).executeAsync(fullScript).then((res) => {
|
||||
var result = res && res.value
|
||||
|
||||
if (result && result.message === 'NoSuchElement') {
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
export default selectorExecuteAsync
|
||||
38
static/js/ketcher2/node_modules/webdriverio/lib/commands/setCookie.js
generated
vendored
Normal file
38
static/js/ketcher2/node_modules/webdriverio/lib/commands/setCookie.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
*
|
||||
* Sets a [cookie](https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#cookie-json-object)
|
||||
* for current page. Make sure you are on the page that should receive the cookie. You can't set
|
||||
* a cookie for an arbitrary page without being on that page.
|
||||
*
|
||||
* <example>
|
||||
:setCookie.js
|
||||
it('should set a cookie for the page', function () {
|
||||
browser.url('/')
|
||||
browser.setCookie({name: 'test', value: '123'});
|
||||
|
||||
var cookies = browser.getCookie();
|
||||
console.log(cookies); // outputs: [{ name: 'test', value: '123' }]
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.setCookie
|
||||
* @param {Object} cookie cookie object
|
||||
* @uses protocol/cookie
|
||||
* @type cookie
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let setCookie = function (cookieObj) {
|
||||
/*!
|
||||
* parameter check
|
||||
*/
|
||||
if (typeof cookieObj !== 'object') {
|
||||
throw new CommandError('Please specify a cookie object to set (see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#cookie-json-object for documentation.')
|
||||
}
|
||||
|
||||
return this.cookie('POST', cookieObj)
|
||||
}
|
||||
|
||||
export default setCookie
|
||||
28
static/js/ketcher2/node_modules/webdriverio/lib/commands/setGeoLocation.js
generated
vendored
Normal file
28
static/js/ketcher2/node_modules/webdriverio/lib/commands/setGeoLocation.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
*
|
||||
* Set the current geo location.
|
||||
*
|
||||
* @alias browser.setGeoLocation
|
||||
* @param {Object} location the new location (`{latitude: number, longitude: number, altitude: number}`)
|
||||
* @uses protocol/location
|
||||
* @type mobile
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let setGeoLocation = function (location) {
|
||||
/*!
|
||||
* parameter check
|
||||
*/
|
||||
if (typeof location !== 'object' ||
|
||||
location.latitude === undefined ||
|
||||
location.longitude === undefined ||
|
||||
location.altitude === undefined) {
|
||||
throw new CommandError('location object need to have a latitude, longitude and altitude attribute')
|
||||
}
|
||||
|
||||
return this.location(location)
|
||||
}
|
||||
|
||||
export default setGeoLocation
|
||||
36
static/js/ketcher2/node_modules/webdriverio/lib/commands/setOrientation.js
generated
vendored
Normal file
36
static/js/ketcher2/node_modules/webdriverio/lib/commands/setOrientation.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
*
|
||||
* Set a device orientation.
|
||||
*
|
||||
* <example>
|
||||
:setOrientation.js
|
||||
it('should set a geo location for the device', function () {
|
||||
browser.setOrientation('landscape');
|
||||
|
||||
var orientation = browser.getOrientation();
|
||||
console.log(orientation); // outputs: "landscape"
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.setOrientation
|
||||
* @param {String} orientation the new browser orientation (`landscape/portrait`)
|
||||
* @uses protocol/orientation
|
||||
* @type mobile
|
||||
* @for android, ios
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let setOrientation = function (orientation) {
|
||||
/*!
|
||||
* parameter check
|
||||
*/
|
||||
if (typeof orientation !== 'string') {
|
||||
throw new CommandError('number or type of arguments don\'t agree with setOrientation command')
|
||||
}
|
||||
|
||||
return this.orientation(orientation.toUpperCase())
|
||||
}
|
||||
|
||||
export default setOrientation
|
||||
61
static/js/ketcher2/node_modules/webdriverio/lib/commands/setValue.js
generated
vendored
Normal file
61
static/js/ketcher2/node_modules/webdriverio/lib/commands/setValue.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
*
|
||||
* Send a sequence of key strokes to an element (clears value before). You can also use
|
||||
* unicode characters like Left arrow or Back space. WebdriverIO will take care of
|
||||
* translating them into unicode characters. You’ll find all supported characters
|
||||
* [here](https://w3c.github.io/webdriver/webdriver-spec.html#dfn-character-types).
|
||||
* To do that, the value has to correspond to a key from the table.
|
||||
*
|
||||
* <example>
|
||||
:setValue.js
|
||||
it('should set value for a certain element', function () {
|
||||
var input = $('.input');
|
||||
input.setValue('test123');
|
||||
|
||||
// same as
|
||||
browser.setValue('.input', 'test123');
|
||||
|
||||
console.log(input.getValue()); // outputs: 'test123'
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.setValue
|
||||
* @param {String} selector Input element
|
||||
* @param {String|Number|Array} values Input element
|
||||
* @uses protocol/elements, protocol/elementIdClear, protocol/elementIdValue
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let setValue = function (selector, value) {
|
||||
/*!
|
||||
* parameter check
|
||||
*/
|
||||
if (typeof value === 'number') {
|
||||
value = value.toString()
|
||||
}
|
||||
|
||||
if (typeof value !== 'string' && !Array.isArray(value)) {
|
||||
throw new CommandError('number or type of arguments don\'t agree with setValue command')
|
||||
}
|
||||
|
||||
return this.elements(selector).then((res) => {
|
||||
/**
|
||||
* throw NoSuchElement error if no element was found
|
||||
*/
|
||||
if (!res.value || res.value.length === 0) {
|
||||
throw new CommandError(7, selector || this.lastResult.selector)
|
||||
}
|
||||
|
||||
let elementIdValueCommands = []
|
||||
for (let elem of res.value) {
|
||||
elementIdValueCommands.push(this.elementIdClear(elem.ELEMENT).elementIdValue(elem.ELEMENT, value))
|
||||
}
|
||||
|
||||
return this.unify(elementIdValueCommands)
|
||||
})
|
||||
}
|
||||
|
||||
export default setValue
|
||||
86
static/js/ketcher2/node_modules/webdriverio/lib/commands/setViewportSize.js
generated
vendored
Normal file
86
static/js/ketcher2/node_modules/webdriverio/lib/commands/setViewportSize.js
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
/**
|
||||
*
|
||||
* This command changes the viewport size of the browser. When talking about browser size we have to differentiate
|
||||
* between the actual window size of the browser application and the document/viewport size of the website. The
|
||||
* window size will always be bigger since it includes the height of any menu or status bars.
|
||||
*
|
||||
* The command tries to resize the browser multiple times (max 5 times) because Webdriver only allows to change
|
||||
* the window size and doesn't take the viewport into consideration. This is handled by WebdriverIO internally.
|
||||
*
|
||||
* <example>
|
||||
:setViewportSize.js
|
||||
it('should resize the current viewport', function () {
|
||||
browser.setViewportSize({
|
||||
width: 500,
|
||||
height: 500
|
||||
});
|
||||
|
||||
var windowSize = browser.windowHandleSize();
|
||||
console.log(windowSize.value); // outputs: { width: 500, height: 602 }
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.setViewportSize
|
||||
* @param {Object} size window width/height
|
||||
* @param {Boolean} type set to `false` to change window size, `true` (default) to change viewport size
|
||||
* @uses protocol/execute, protocol/windowHandleSize
|
||||
* @type window
|
||||
*
|
||||
*/
|
||||
|
||||
import getViewportSize from '../scripts/getViewportSize'
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
const MAX_TRIES = 5
|
||||
|
||||
let setViewportSize = function (size, type) {
|
||||
/**
|
||||
* parameter check
|
||||
*/
|
||||
if (typeof size !== 'object' ||
|
||||
typeof size.width !== 'number' ||
|
||||
typeof size.height !== 'number' ||
|
||||
(typeof type !== 'undefined' && typeof type !== 'boolean')) {
|
||||
throw new CommandError('number or type of arguments don\'t agree with setViewportSize command')
|
||||
}
|
||||
|
||||
let shouldIndent = (typeof type === 'undefined') ? true : type
|
||||
return shouldIndent ? _setViewportSize.call(this, size) : this.windowHandleSize(size)
|
||||
}
|
||||
|
||||
/**
|
||||
* to set viewport size properly we need to execute the process multiple times
|
||||
* since the difference between the inner and outer size changes when browser
|
||||
* switch between fullscreen modes or visibility of scrollbar
|
||||
*/
|
||||
let _setViewportSize = function (size, retryNo = 0) {
|
||||
/**
|
||||
* get window size
|
||||
*/
|
||||
return this.windowHandleSize().then((windowHandleSize) => {
|
||||
/**
|
||||
* get viewport size
|
||||
*/
|
||||
return this.execute(getViewportSize).then((viewportSize) => {
|
||||
let widthDiff = windowHandleSize.value.width - viewportSize.value.screenWidth
|
||||
let heightDiff = windowHandleSize.value.height - viewportSize.value.screenHeight
|
||||
|
||||
/**
|
||||
* change window size with indent
|
||||
*/
|
||||
return this.windowHandleSize({
|
||||
width: size.width + widthDiff,
|
||||
height: size.height + heightDiff
|
||||
})
|
||||
}).execute(getViewportSize).then((res) => {
|
||||
/**
|
||||
* if viewport size not equals desired size, execute process again
|
||||
*/
|
||||
if (retryNo < MAX_TRIES && (res.value.screenWidth !== size.width || res.value.screenHeight !== size.height)) {
|
||||
return _setViewportSize.call(this, size, ++retryNo)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default setViewportSize
|
||||
46
static/js/ketcher2/node_modules/webdriverio/lib/commands/submitForm.js
generated
vendored
Normal file
46
static/js/ketcher2/node_modules/webdriverio/lib/commands/submitForm.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
*
|
||||
* Submits a form found by given selector. The submit command may also be applied
|
||||
* to any element that is a descendant of a `<form>` element.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<form action="/form.php" method="post" id="loginForm">
|
||||
<label for="username">User:</label>
|
||||
<input type="text" name="username" id="username">
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" name="password" id="password">
|
||||
<input type="submit" value="Login">
|
||||
</form>
|
||||
|
||||
:submitForm.js
|
||||
it('should submit login form', function () {
|
||||
browser.setValue('#username', 'foobar');
|
||||
browser.setValue('#password', 'test123');
|
||||
browser.submitForm('#loginForm');
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.submitForm
|
||||
* @param {String} selector form element
|
||||
* @uses protocol/element, protocol/submit
|
||||
* @type action
|
||||
*
|
||||
*/
|
||||
|
||||
import { RuntimeError } from '../utils/ErrorHandler'
|
||||
|
||||
let submitForm = function (selector) {
|
||||
return this.element(selector).then((res) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!res.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
return this.submit(res.value.ELEMENT)
|
||||
})
|
||||
}
|
||||
|
||||
export default submitForm
|
||||
47
static/js/ketcher2/node_modules/webdriverio/lib/commands/swipe.js
generated
vendored
Normal file
47
static/js/ketcher2/node_modules/webdriverio/lib/commands/swipe.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
*
|
||||
* Perform a swipe on the screen or an element. If you want to swipe on a specific
|
||||
* element make sure you provide a selector argument. If not just pass `xoffset`
|
||||
* and `yoffset` as command arguments.
|
||||
*
|
||||
* Start at a particular screen location.
|
||||
*
|
||||
* @alias browser.swipe
|
||||
* @param {String=} selector element to swipe on
|
||||
* @param {Number=} xoffset x offset of swipe gesture (in pixels or relative units)
|
||||
* @param {Number=} yoffset y offset of swipe gesture (in pixels or relative units)
|
||||
* @param {Number=} speed time (in seconds) to spend performing the swipe
|
||||
* @uses protocol/element, protocol/touchFlick
|
||||
* @type mobile
|
||||
*
|
||||
*/
|
||||
|
||||
import { RuntimeError } from '../utils/ErrorHandler'
|
||||
|
||||
let swipe = function (selector, xoffset, yoffset, speed) {
|
||||
if (arguments.length === 2 && typeof selector === 'number' && typeof xoffset === 'number') {
|
||||
/*!
|
||||
* you don't care where the swipe starts on the screen
|
||||
*/
|
||||
let xspeed = selector
|
||||
let yspeed = xoffset
|
||||
|
||||
return this.touchFlick(xspeed, yspeed)
|
||||
}
|
||||
|
||||
/*!
|
||||
* command starts at a particular screen location
|
||||
*/
|
||||
return this.element(selector).then((res) => {
|
||||
/**
|
||||
* check if element was found and throw error if not
|
||||
*/
|
||||
if (!res.value) {
|
||||
throw new RuntimeError(7)
|
||||
}
|
||||
|
||||
return this.touchFlick(res.value.ELEMENT.toString(), xoffset, yoffset, speed)
|
||||
})
|
||||
}
|
||||
|
||||
export default swipe
|
||||
30
static/js/ketcher2/node_modules/webdriverio/lib/commands/swipeDown.js
generated
vendored
Normal file
30
static/js/ketcher2/node_modules/webdriverio/lib/commands/swipeDown.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
*
|
||||
* Perform a swipe down on an element.
|
||||
*
|
||||
* @alias browser.swipeDown
|
||||
* @param {String} selector element to swipe on
|
||||
* @param {Number=} yoffset y offset of swipe gesture (in pixels or relative units)
|
||||
* @param {Number} speed number of pixels go per second
|
||||
* @uses mobile/swipe
|
||||
* @type mobile
|
||||
*
|
||||
*/
|
||||
|
||||
let swipeDown = function (selector, yOffset, speed) {
|
||||
/**
|
||||
* we can't use default values for function parameter here because this would
|
||||
* break the ability to chain the command with an element if reverse is used
|
||||
*/
|
||||
yOffset = typeof yOffset === 'number' ? yOffset : 100
|
||||
speed = typeof speed === 'number' ? speed : 100
|
||||
|
||||
/**
|
||||
* make sure yoffset is positive so we scroll up
|
||||
*/
|
||||
yOffset = yOffset < 0 ? yOffset * -1 : yOffset
|
||||
|
||||
return this.pause(100).swipe(selector, 0, yOffset, speed)
|
||||
}
|
||||
|
||||
export default swipeDown
|
||||
30
static/js/ketcher2/node_modules/webdriverio/lib/commands/swipeLeft.js
generated
vendored
Normal file
30
static/js/ketcher2/node_modules/webdriverio/lib/commands/swipeLeft.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
*
|
||||
* Perform a swipe left on an element.
|
||||
*
|
||||
* @alias browser.swipeLeft
|
||||
* @param {String} selector element to swipe on
|
||||
* @param {Number=} xoffset x offset of swipe gesture (in pixels or relative units)
|
||||
* @param {Number} speed time (in seconds) to spend performing the swipe
|
||||
* @uses mobile/flick
|
||||
* @type mobile
|
||||
*
|
||||
*/
|
||||
|
||||
let swipeLeft = function (selector, xOffset, speed) {
|
||||
/**
|
||||
* we can't use default values for function parameter here because this would
|
||||
* break the ability to chain the command with an element if reverse is used
|
||||
*/
|
||||
xOffset = typeof xOffset === 'number' ? xOffset : 100
|
||||
speed = typeof speed === 'number' ? speed : 100
|
||||
|
||||
/**
|
||||
* make sure xoffset is positive so we scroll right
|
||||
*/
|
||||
xOffset = xOffset > 0 ? xOffset * -1 : xOffset
|
||||
|
||||
return this.pause(100).swipe(selector, xOffset, 0, speed)
|
||||
}
|
||||
|
||||
export default swipeLeft
|
||||
30
static/js/ketcher2/node_modules/webdriverio/lib/commands/swipeRight.js
generated
vendored
Normal file
30
static/js/ketcher2/node_modules/webdriverio/lib/commands/swipeRight.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
*
|
||||
* Perform a swipe right on an element.
|
||||
*
|
||||
* @alias browser.swipeRight
|
||||
* @param {String} selector element to swipe on
|
||||
* @param {Number=} xoffset x offset of swipe gesture (in pixels or relative units)
|
||||
* @param {Number} speed time (in seconds) to spend performing the swipe
|
||||
* @uses mobile/swipe
|
||||
* @type mobile
|
||||
*
|
||||
*/
|
||||
|
||||
let swipeRight = function (selector, xOffset, speed) {
|
||||
/**
|
||||
* we can't use default values for function parameter here because this would
|
||||
* break the ability to chain the command with an element if reverse is used
|
||||
*/
|
||||
xOffset = typeof xOffset === 'number' ? xOffset : -100
|
||||
speed = typeof speed === 'number' ? speed : 100
|
||||
|
||||
/**
|
||||
* make sure xoffset is negative so we scroll left
|
||||
*/
|
||||
xOffset = xOffset < 0 ? xOffset * -1 : xOffset
|
||||
|
||||
return this.pause(100).swipe(selector, xOffset, 0, speed)
|
||||
}
|
||||
|
||||
export default swipeRight
|
||||
30
static/js/ketcher2/node_modules/webdriverio/lib/commands/swipeUp.js
generated
vendored
Normal file
30
static/js/ketcher2/node_modules/webdriverio/lib/commands/swipeUp.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
*
|
||||
* Perform a swipe up on an element.
|
||||
*
|
||||
* @alias browser.swipeUp
|
||||
* @param {String} selector element to swipe on
|
||||
* @param {Number=} yoffset y offset of swipe gesture (in pixels or relative units)
|
||||
* @param {Number} speed time (in seconds) to spend performing the swipe
|
||||
* @uses mobile/swipe
|
||||
* @type mobile
|
||||
*
|
||||
*/
|
||||
|
||||
let swipeUp = function (selector, yOffset, speed) {
|
||||
/**
|
||||
* we can't use default values for function parameter here because this would
|
||||
* break the ability to chain the command with an element if reverse is used
|
||||
*/
|
||||
yOffset = typeof yOffset === 'number' ? yOffset : -100
|
||||
speed = typeof speed === 'number' ? speed : 100
|
||||
|
||||
/**
|
||||
* make sure yoffset is negative so we scroll down
|
||||
*/
|
||||
yOffset = yOffset > 0 ? yOffset * -1 : yOffset
|
||||
|
||||
return this.pause(100).swipe(selector, 0, yOffset, speed)
|
||||
}
|
||||
|
||||
export default swipeUp
|
||||
31
static/js/ketcher2/node_modules/webdriverio/lib/commands/switchTab.js
generated
vendored
Normal file
31
static/js/ketcher2/node_modules/webdriverio/lib/commands/switchTab.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
*
|
||||
* Switch focus to a particular tab / window handle.
|
||||
*
|
||||
* @alias browser.switchTab
|
||||
* @param {String=} windowHandle window handle URL to focus on (if no handle was specified the command switches to the first available one)
|
||||
* @uses protocol/window, window/getTabIds, window/switchTab
|
||||
* @type window
|
||||
*
|
||||
*/
|
||||
|
||||
let switchTab = function (windowHandle) {
|
||||
/*!
|
||||
* parameter check
|
||||
*/
|
||||
if (typeof windowHandle !== 'string') {
|
||||
windowHandle = null
|
||||
}
|
||||
|
||||
if (windowHandle) {
|
||||
return this.window(windowHandle)
|
||||
}
|
||||
|
||||
return this.windowHandles().then((tabIds) => {
|
||||
if (tabIds && tabIds.value && tabIds.value.length) {
|
||||
return this.switchTab(tabIds.value[0])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default switchTab
|
||||
26
static/js/ketcher2/node_modules/webdriverio/lib/commands/touch.js
generated
vendored
Normal file
26
static/js/ketcher2/node_modules/webdriverio/lib/commands/touch.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Put finger on an element (only in mobile context).
|
||||
*
|
||||
* @alias browser.touch
|
||||
* @param {String} selector element to put finger on
|
||||
* @param {Boolean} longClick if true touch click will be long (default: false)
|
||||
* @uses property/getLocation, protocol/touchClick
|
||||
* @type mobile
|
||||
* @uses android
|
||||
*
|
||||
*/
|
||||
|
||||
let touch = function (selector, longClick) {
|
||||
/**
|
||||
* we can't use default values for function parameter here because this would
|
||||
* break the ability to chain the command with an element if reverse is used
|
||||
*/
|
||||
longClick = typeof longClick === 'boolean' ? longClick : false
|
||||
|
||||
const touchCommand = longClick ? 'touchLongClick' : 'touchClick'
|
||||
|
||||
return this.getLocation(selector).then((val) =>
|
||||
this[touchCommand](val.x, val.y))
|
||||
}
|
||||
|
||||
export default touch
|
||||
284
static/js/ketcher2/node_modules/webdriverio/lib/commands/touchAction.js
generated
vendored
Normal file
284
static/js/ketcher2/node_modules/webdriverio/lib/commands/touchAction.js
generated
vendored
Normal file
@ -0,0 +1,284 @@
|
||||
/**
|
||||
*
|
||||
* The Touch Action API provides the basis of all gestures that can be automated in Appium.
|
||||
* It is currently only available to native apps and can not be used to interact with webapps.
|
||||
* At its core is the ability to chain together _ad hoc_ individual actions, which will then be
|
||||
* applied to an element in the application on the device. The basic actions that can be used are:
|
||||
*
|
||||
* - press (pass selector or (x,y) or both)
|
||||
* - longPress (pass selector or (x,y) or both)
|
||||
* - tap (pass selector or (x,y) or both)
|
||||
* - moveTo (pass selector or (x,y) or both)
|
||||
* - wait (pass ms (as milliseconds))
|
||||
* - release (no arguments)
|
||||
*
|
||||
* If you use the touchAction command with a selector you don't need to pass the selector to each
|
||||
* action. It will be propagated by the internally (if no x or y parameters are given).
|
||||
*
|
||||
* <example>
|
||||
:touchAction.js
|
||||
it('should do a touch gesture', function () {
|
||||
var screen = $('//UITextbox');
|
||||
|
||||
// simple touch action on element
|
||||
screen.touchAction('tap');
|
||||
// same as
|
||||
browser.touchAction('//UITextbox', 'tap')
|
||||
|
||||
// simple touch action using x y variables
|
||||
browser.touchAction({
|
||||
actions: 'tap', x: 300, y:200
|
||||
})
|
||||
|
||||
// simple touch action using selector and x y variables
|
||||
// tap location is 30px right and 20px down relative from the center of the element
|
||||
browser.touchAction({
|
||||
actions: 'tap', x: 30, y:20, selector: '//UIAApplication[1]/UIAElement[2]'
|
||||
})
|
||||
|
||||
// multi action on an element (drag&drop)
|
||||
screen.touchAction([
|
||||
'press',
|
||||
{ action: 'moveTo', x: 200, y: 0 },
|
||||
'release'
|
||||
])
|
||||
// same as
|
||||
browser.touchAction('//UITextbox', [
|
||||
'press',
|
||||
{ action: 'moveTo', x: 200, y: 0},
|
||||
'release'
|
||||
])
|
||||
|
||||
// drag&drop to element
|
||||
screen.touchAction([
|
||||
'press',
|
||||
{ action: 'moveTo', selector: '//UIAApplication[1]/UIAElement[2]' },
|
||||
'release'
|
||||
]))
|
||||
});
|
||||
|
||||
:multiTouchAction.js
|
||||
it('should do a multitouch gesture', function () {
|
||||
// drag&drop with two fingers 200px down
|
||||
browser.touchAction([
|
||||
[{action: 'press', x: 10, y: 10}, { action: 'moveTo', x: 0, y: 200 }, 'release'],
|
||||
[{action: 'press', x: 100, y: 10}, { action: 'moveTo', x: 0, y: 200 }, 'release']]
|
||||
])
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @param {String} selector selector to execute the touchAction on
|
||||
* @param {String} action action to execute
|
||||
*
|
||||
* @see https://saucelabs.com/blog/appium-sauce-labs-bootcamp-chapter-2-touch-actions
|
||||
* @type mobile
|
||||
* @for android, ios
|
||||
* @uses mobile/performTouchAction, mobile/performMultiAction
|
||||
*
|
||||
*/
|
||||
|
||||
const TOUCH_ACTIONS = ['press', 'longPress', 'tap', 'moveTo', 'wait', 'release']
|
||||
const POS_ACTIONS = TOUCH_ACTIONS.slice(0, -2)
|
||||
const ACCEPTED_OPTIONS = ['x', 'y', 'selector', 'element']
|
||||
|
||||
export default function touchAction (selector, actions) {
|
||||
if (typeof selector !== 'string' || TOUCH_ACTIONS.indexOf(selector) > -1) {
|
||||
actions = selector
|
||||
selector = this.lastResult
|
||||
}
|
||||
|
||||
if (!Array.isArray(actions)) {
|
||||
actions = [actions]
|
||||
}
|
||||
|
||||
/**
|
||||
* check if multiAction
|
||||
*/
|
||||
if (Array.isArray(actions[0])) {
|
||||
actions = formatArgs(selector, actions)
|
||||
return Promise.all(getSelectors.call(this, actions, true)).then((jsonElements) => {
|
||||
actions = replaceSelectorsById(actions, jsonElements)
|
||||
return this.performMultiAction({ actions })
|
||||
})
|
||||
}
|
||||
|
||||
actions = formatArgs(selector, actions)
|
||||
return Promise.all(getSelectors.call(this, actions)).then((jsonElements) => {
|
||||
actions = replaceSelectorsById(actions, jsonElements)
|
||||
return this.performTouchAction({ actions })
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* helper to determine if action has proper option arguments
|
||||
* ('press', 'longPress', 'tap', 'moveTo' need at least some kind of position information)
|
||||
* @param {String} action name of action
|
||||
* @param {Object} options action options
|
||||
* @return {Boolean} True if don't need any options or has a position option
|
||||
*/
|
||||
let hasValidActionOptions = function (action, options) {
|
||||
return POS_ACTIONS.indexOf(action) < 0 || (POS_ACTIONS.indexOf(action) > -1 && Object.keys(options).length > 0)
|
||||
}
|
||||
|
||||
let formatArgs = function (selector, actions) {
|
||||
return actions.map((action) => {
|
||||
if (Array.isArray(action)) {
|
||||
return formatArgs(selector, action)
|
||||
}
|
||||
|
||||
const formattedAction = { action: action.action, options: {} }
|
||||
|
||||
/**
|
||||
* propagate selector or element to options object
|
||||
*/
|
||||
if (
|
||||
selector &&
|
||||
// selector is given as string `e.g. browser.touchAction(selector, 'tap')`
|
||||
typeof selector === 'string' &&
|
||||
// don't propagate for actions that don't require element options
|
||||
POS_ACTIONS.indexOf(typeof action === 'string' ? action : formattedAction.action) > -1 &&
|
||||
// don't propagate if user has x and y set
|
||||
!(isFinite(action.x) && isFinite(action.y))
|
||||
) {
|
||||
formattedAction.options.selector = selector
|
||||
} else if (
|
||||
selector &&
|
||||
// selector is given by previous command
|
||||
// e.g. $(selector).touchAction('tap')
|
||||
selector.value &&
|
||||
// don't propagate for actions that don't require element options
|
||||
POS_ACTIONS.indexOf(typeof action === 'string' ? action : formattedAction.action) > -1 &&
|
||||
// don't propagate if user has x and y set
|
||||
!(isFinite(action.x) && isFinite(action.y))
|
||||
) {
|
||||
formattedAction.options.element = selector.value.ELEMENT
|
||||
}
|
||||
|
||||
if (typeof action === 'string') {
|
||||
if (!hasValidActionOptions(action, formattedAction.options)) {
|
||||
throw new Error(
|
||||
`Touch action "${action}" doesn't have proper options. Make sure certain actions like ` +
|
||||
`${POS_ACTIONS.join(', ')} have position options like "selector", "x" or "y".`
|
||||
)
|
||||
}
|
||||
|
||||
formattedAction.action = action
|
||||
|
||||
/**
|
||||
* remove options property if empyt
|
||||
*/
|
||||
if (Object.keys(formattedAction.options).length === 0) {
|
||||
delete formattedAction.options
|
||||
}
|
||||
|
||||
return formattedAction
|
||||
}
|
||||
|
||||
if (isFinite(action.x)) formattedAction.options.x = action.x
|
||||
if (isFinite(action.y)) formattedAction.options.y = action.y
|
||||
if (action.ms) formattedAction.options.ms = action.ms
|
||||
|
||||
if (action.selector && POS_ACTIONS.indexOf(formattedAction.action) > -1) {
|
||||
formattedAction.options.selector = action.selector
|
||||
}
|
||||
|
||||
if (action.element) {
|
||||
formattedAction.options.element = action.element
|
||||
delete formattedAction.options.selector
|
||||
}
|
||||
|
||||
/**
|
||||
* remove options property if empyt
|
||||
*/
|
||||
if (Object.keys(formattedAction.options).length === 0) {
|
||||
delete formattedAction.options
|
||||
}
|
||||
|
||||
/**
|
||||
* option check
|
||||
* make sure action has proper options before sending command to Appium
|
||||
*/
|
||||
if (formattedAction.action === 'release' && formattedAction.options) {
|
||||
throw new Error(
|
||||
'action "release" doesn\'t accept any options ' +
|
||||
`("${Object.keys(formattedAction.options).join('", "')}" found)`
|
||||
)
|
||||
} else if (
|
||||
formattedAction.action === 'wait' &&
|
||||
(Object.keys(formattedAction.options).indexOf('x') > -1 || Object.keys(formattedAction.options).indexOf('y') > -1)
|
||||
) {
|
||||
throw new Error('action "wait" doesn\'t accept x, y options')
|
||||
} else if (POS_ACTIONS.indexOf(formattedAction.action) > -1) {
|
||||
for (const option in formattedAction.options) {
|
||||
if (ACCEPTED_OPTIONS.indexOf(option) === -1) {
|
||||
throw new Error(`action "${formattedAction.action}" doesn't accept "${option}" as option`)
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(formattedAction.options || {}).length === 0) {
|
||||
throw new Error(
|
||||
`Touch actions like "${formattedAction.action}" need at least some kind of ` +
|
||||
'position information like "selector", "x" or "y" options, you\'ve none given.'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return formattedAction
|
||||
})
|
||||
}
|
||||
|
||||
let getSelectors = function (actions, isMultiAction = false) {
|
||||
let queriedSelectors = []
|
||||
|
||||
/**
|
||||
* flatten actions array
|
||||
*/
|
||||
if (isMultiAction) {
|
||||
actions = [].concat.apply([], actions)
|
||||
}
|
||||
|
||||
return actions
|
||||
/**
|
||||
* map down to list of selectors
|
||||
*/
|
||||
.map((action) => action.options && action.options.selector)
|
||||
/**
|
||||
* filter actions without selector and unique selectors
|
||||
*/
|
||||
.filter((selector) => {
|
||||
const res = Boolean(selector) && queriedSelectors.indexOf(selector) === -1
|
||||
queriedSelectors.push(selector)
|
||||
return res
|
||||
})
|
||||
/**
|
||||
* call element command on selectors
|
||||
*/
|
||||
.map((selector) => this.element(selector))
|
||||
}
|
||||
|
||||
/**
|
||||
* replaces selector action properties with element ids after they got fetched
|
||||
* @param {Object[]} actions list of actions
|
||||
* @param {Object[]} elements list of fetched elements
|
||||
* @return {Object[]} list of actions with proper element ids
|
||||
*/
|
||||
let replaceSelectorsById = function (actions, elements) {
|
||||
return actions.map((action) => {
|
||||
if (Array.isArray(action)) {
|
||||
return replaceSelectorsById(action, elements)
|
||||
}
|
||||
|
||||
if (!action.options || !action.options.selector) {
|
||||
return action
|
||||
}
|
||||
|
||||
elements.forEach((element) => {
|
||||
if (action.options.selector === element.selector) {
|
||||
action.options.element = element.value.ELEMENT
|
||||
delete action.options.selector
|
||||
}
|
||||
})
|
||||
|
||||
return action
|
||||
})
|
||||
}
|
||||
45
static/js/ketcher2/node_modules/webdriverio/lib/commands/uploadFile.js
generated
vendored
Normal file
45
static/js/ketcher2/node_modules/webdriverio/lib/commands/uploadFile.js
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
*
|
||||
* Uploads a file to the selenium server by using the [`file`](/api/protocol/file.html) command. Note that
|
||||
* this command might not be supported as it is an undocumented Selenium command.
|
||||
*
|
||||
* @alias browser.uploadFile
|
||||
* @param {String} localPath local path to file
|
||||
* @type utility
|
||||
* @uses protocol/file
|
||||
*
|
||||
*/
|
||||
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import archiver from 'archiver'
|
||||
|
||||
import { CommandError } from '../utils/ErrorHandler'
|
||||
|
||||
let uploadFile = function (localPath) {
|
||||
/*!
|
||||
* parameter check
|
||||
*/
|
||||
if (typeof localPath !== 'string') {
|
||||
throw new CommandError('number or type of arguments don\'t agree with uploadFile command')
|
||||
}
|
||||
|
||||
let zipData = []
|
||||
let source = fs.createReadStream(localPath)
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
archiver('zip')
|
||||
.on('error', (e) => { throw new Error(e) })
|
||||
.on('data', (data) => zipData.push(data))
|
||||
.on('end', () => this.file(Buffer.concat(zipData).toString('base64')).then(resolve, reject))
|
||||
.append(source, { name: path.basename(localPath) })
|
||||
.finalize((err) => {
|
||||
/* istanbul ignore next */
|
||||
if (err) {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default uploadFile
|
||||
78
static/js/ketcher2/node_modules/webdriverio/lib/commands/waitForEnabled.js
generated
vendored
Normal file
78
static/js/ketcher2/node_modules/webdriverio/lib/commands/waitForEnabled.js
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
/**
|
||||
*
|
||||
* Wait for an element (selected by css selector) for the provided amount of
|
||||
* milliseconds to be (dis/en)abled. If multiple elements get queryied by given
|
||||
* selector, it returns true (or false if reverse flag is set) if at least one
|
||||
* element is (dis/en)abled.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<input type="text" id="username" value="foobar" disabled="disabled"></input>
|
||||
<script type="text/javascript">
|
||||
setTimeout(function () {
|
||||
document.getElementById('username').disabled = false
|
||||
}, 2000);
|
||||
</script>
|
||||
|
||||
:waitForEnabledExample.js
|
||||
it('should detect when element is enabled', function () {
|
||||
browser.waitForEnabled('#username', 3000);
|
||||
|
||||
// same as
|
||||
elem = $('#username');
|
||||
elem.waitForEnabled(3000)
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.waitForEnabled
|
||||
* @param {String} selector element to wait for
|
||||
* @param {Number=} ms time in ms (default: 500)
|
||||
* @param {Boolean=} reverse if true it waits for the opposite (default: false)
|
||||
* @uses utility/waitUntil, state/isEnabled
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
let waitForEnabled = function (selector, ms, reverse) {
|
||||
/**
|
||||
* we can't use default values for function parameter here because this would
|
||||
* break the ability to chain the command with an element if reverse is used, like
|
||||
*
|
||||
* ```js
|
||||
* var elem = $('#elem');
|
||||
* elem.waitForXXX(10000, true);
|
||||
* ```
|
||||
*/
|
||||
reverse = typeof reverse === 'boolean' ? reverse : false
|
||||
|
||||
/*!
|
||||
* ensure that ms is set properly
|
||||
*/
|
||||
if (typeof ms !== 'number') {
|
||||
ms = this.options.waitforTimeout
|
||||
}
|
||||
|
||||
const isReversed = reverse ? '' : 'not'
|
||||
const errorMsg = `element ("${selector || this.lastResult.selector}") still ${isReversed} enabled after ${ms}ms`
|
||||
|
||||
return this.waitUntil(() => {
|
||||
return this.isEnabled(selector).then((isEnabled) => {
|
||||
if (!Array.isArray(isEnabled)) {
|
||||
return isEnabled !== reverse
|
||||
}
|
||||
|
||||
var result = reverse
|
||||
for (let val of isEnabled) {
|
||||
if (!reverse) {
|
||||
result = result || val
|
||||
} else {
|
||||
result = result && val
|
||||
}
|
||||
}
|
||||
|
||||
return result !== reverse
|
||||
})
|
||||
}, ms, errorMsg)
|
||||
}
|
||||
|
||||
export default waitForEnabled
|
||||
72
static/js/ketcher2/node_modules/webdriverio/lib/commands/waitForExist.js
generated
vendored
Normal file
72
static/js/ketcher2/node_modules/webdriverio/lib/commands/waitForExist.js
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
*
|
||||
* Wait for an element (selected by css selector) for the provided amount of
|
||||
* milliseconds to be present within the DOM. Returns true if the selector
|
||||
* matches at least one element that exists in the DOM, otherwise throws an
|
||||
* error. If the reverse flag is true, the command will instead return true
|
||||
* if the selector does not match any elements.
|
||||
*
|
||||
* <example>
|
||||
:waitForExistSyncExample.js
|
||||
it('should display a notification message after successful form submit', function () {
|
||||
var form = $('form');
|
||||
var notification = $('.notification');
|
||||
|
||||
form.submit();
|
||||
notification.waitForExist(5000); // same as `browser.waitForExist('.notification', 5000)`
|
||||
expect(notification.getText()).to.be.equal('Data transmitted successfully!')
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.waitForExist
|
||||
* @param {String} selector CSS selector to query
|
||||
* @param {Number=} ms time in ms (default: 500)
|
||||
* @param {Boolean=} reverse if true it instead waits for the selector to not match any elements (default: false)
|
||||
* @uses utility/waitUntil, state/isExisting
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
let waitForExist = function (selector, ms, reverse) {
|
||||
/**
|
||||
* we can't use default values for function parameter here because this would
|
||||
* break the ability to chain the command with an element if reverse is used, like
|
||||
*
|
||||
* ```js
|
||||
* var elem = $('#elem');
|
||||
* elem.waitForXXX(10000, true);
|
||||
* ```
|
||||
*/
|
||||
reverse = typeof reverse === 'boolean' ? reverse : false
|
||||
|
||||
/*!
|
||||
* ensure that ms is set properly
|
||||
*/
|
||||
if (typeof ms !== 'number') {
|
||||
ms = this.options.waitforTimeout
|
||||
}
|
||||
|
||||
const isReversed = reverse ? '' : 'not'
|
||||
const errorMsg = `element ("${selector || this.lastResult.selector}") still ${isReversed} existing after ${ms}ms`
|
||||
|
||||
return this.waitUntil(() => {
|
||||
return this.isExisting(selector).then((isExisting) => {
|
||||
if (!Array.isArray(isExisting)) {
|
||||
return isExisting !== reverse
|
||||
}
|
||||
|
||||
let result = reverse
|
||||
for (let val of isExisting) {
|
||||
if (!reverse) {
|
||||
result = result || val
|
||||
} else {
|
||||
result = result && val
|
||||
}
|
||||
}
|
||||
|
||||
return result !== reverse
|
||||
})
|
||||
}, ms, errorMsg)
|
||||
}
|
||||
|
||||
export default waitForExist
|
||||
81
static/js/ketcher2/node_modules/webdriverio/lib/commands/waitForSelected.js
generated
vendored
Normal file
81
static/js/ketcher2/node_modules/webdriverio/lib/commands/waitForSelected.js
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
/**
|
||||
*
|
||||
* Wait for an option or radio/checkbox element (selected by css selector) for the provided amount of
|
||||
* milliseconds to be (un)selected or (un)checked. If multiple elements get queryied by given
|
||||
* selector, it returns true (or false if reverse flag is set) if at least one element is (un)selected.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<select>
|
||||
<option value="1" id="option1">1</option>
|
||||
<option value="2" id="option2" selected="selected">2</option>
|
||||
<option value="3" id="option3">3</option>
|
||||
</select>
|
||||
<script type="text/javascript">
|
||||
setTimeout(function () {
|
||||
document.getElementById('option1').selected = true;
|
||||
}, 2000);
|
||||
</script>
|
||||
|
||||
:waitForSelectedExample.js
|
||||
it('should detect when an option is selected', function () {
|
||||
browser.waitForSelected('#option1', 3000);
|
||||
|
||||
// same as
|
||||
elem = $('#option1');
|
||||
elem.waitForSelected(3000)
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.waitForSelected
|
||||
* @param {String} selector element to wait for
|
||||
* @param {Number=} ms time in ms (default: 500)
|
||||
* @param {Boolean=} reverse if true it waits for the opposite (default: false)
|
||||
* @uses utility/waitUntil, state/isSelected
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
let waitForSelected = function (selector, ms, reverse) {
|
||||
/**
|
||||
* we can't use default values for function parameter here because this would
|
||||
* break the ability to chain the command with an element if reverse is used, like
|
||||
*
|
||||
* ```js
|
||||
* var elem = $('#elem');
|
||||
* elem.waitForXXX(10000, true);
|
||||
* ```
|
||||
*/
|
||||
reverse = typeof reverse === 'boolean' ? reverse : false
|
||||
|
||||
/*!
|
||||
* ensure that ms is set properly
|
||||
*/
|
||||
if (typeof ms !== 'number') {
|
||||
ms = this.options.waitforTimeout
|
||||
}
|
||||
|
||||
const isReversed = reverse ? '' : 'not'
|
||||
const errorMsg = `element ("${selector || this.lastResult.selector}") still ${isReversed} selected after ${ms}ms`
|
||||
|
||||
return this.waitUntil(() => {
|
||||
return this.isSelected(selector).then((isSelected) => {
|
||||
if (!Array.isArray(isSelected)) {
|
||||
return isSelected !== reverse
|
||||
}
|
||||
|
||||
let result = reverse
|
||||
for (let val of isSelected) {
|
||||
if (!reverse) {
|
||||
result = result || val
|
||||
} else {
|
||||
result = result && val
|
||||
}
|
||||
}
|
||||
|
||||
return result !== reverse
|
||||
})
|
||||
}, ms, errorMsg)
|
||||
}
|
||||
|
||||
export default waitForSelected
|
||||
78
static/js/ketcher2/node_modules/webdriverio/lib/commands/waitForText.js
generated
vendored
Normal file
78
static/js/ketcher2/node_modules/webdriverio/lib/commands/waitForText.js
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
/**
|
||||
*
|
||||
* Wait for an element (selected by css selector) for the provided amount of
|
||||
* milliseconds to have text/content. If multiple elements get queryied by given
|
||||
* selector, it returns true (or false if reverse flag is set) if at least one
|
||||
* element has text/content.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<div id="elem"></div>
|
||||
<script type="text/javascript">
|
||||
setTimeout(function () {
|
||||
document.getElementById('elem').innerHTML = 'some text';
|
||||
}, 2000);
|
||||
</script>
|
||||
|
||||
:waitForTextExample.js
|
||||
it('should detect when element has text', function () {
|
||||
browser.waitForText('#elem', 3000);
|
||||
|
||||
// same as
|
||||
elem = $('#elem');
|
||||
elem.waitForText(3000)
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.waitForText
|
||||
* @param {String} selector element to wait for
|
||||
* @param {Number=} ms time in ms (default: 500)
|
||||
* @param {Boolean=} reverse if true it waits for the opposite (default: false)
|
||||
* @uses utility/waitUntil, property/getText
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
let waitForText = function (selector, ms, reverse) {
|
||||
/**
|
||||
* we can't use default values for function parameter here because this would
|
||||
* break the ability to chain the command with an element if reverse is used, like
|
||||
*
|
||||
* ```js
|
||||
* var elem = $('#elem');
|
||||
* elem.waitForXXX(10000, true);
|
||||
* ```
|
||||
*/
|
||||
reverse = typeof reverse === 'boolean' ? reverse : false
|
||||
|
||||
/*!
|
||||
* ensure that ms is set properly
|
||||
*/
|
||||
if (typeof ms !== 'number') {
|
||||
ms = this.options.waitforTimeout
|
||||
}
|
||||
|
||||
const isReversed = reverse ? 'with' : 'without'
|
||||
const errorMsg = `element ("${selector || this.lastResult.selector}") still ${isReversed} text after ${ms}ms`
|
||||
|
||||
return this.waitUntil(() => {
|
||||
return this.getText(selector).then((text) => {
|
||||
if (!Array.isArray(text)) {
|
||||
return (text !== '') !== reverse
|
||||
}
|
||||
|
||||
let result = reverse
|
||||
for (let val of text) {
|
||||
if (!reverse) {
|
||||
result = result || val !== ''
|
||||
} else {
|
||||
result = result && val === ''
|
||||
}
|
||||
}
|
||||
|
||||
return result !== reverse
|
||||
})
|
||||
}, ms, errorMsg)
|
||||
}
|
||||
|
||||
export default waitForText
|
||||
78
static/js/ketcher2/node_modules/webdriverio/lib/commands/waitForValue.js
generated
vendored
Normal file
78
static/js/ketcher2/node_modules/webdriverio/lib/commands/waitForValue.js
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
/**
|
||||
*
|
||||
* Wait for an element (selected by css selector) for the provided amount of
|
||||
* milliseconds to have a value. If multiple elements get queryied by given
|
||||
* selector, it returns true (or false if reverse flag is set) if at least one
|
||||
* element has a value.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<input name="someInput" id="elem" value=""></input>
|
||||
<script type="text/javascript">
|
||||
setTimeout(function () {
|
||||
document.getElementById('elem').value = 'some text';
|
||||
}, 2000);
|
||||
</script>
|
||||
|
||||
:waitForValueExample.js
|
||||
it('should detect when element has value', function () {
|
||||
browser.waitForValue('#elem', 3000);
|
||||
|
||||
// same as
|
||||
elem = $('#elem');
|
||||
elem.waitForValue(3000)
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.waitForValue
|
||||
* @param {String} selector element to wait
|
||||
* @param {Number=} ms time in ms (default: 500)
|
||||
* @param {Boolean=} reverse if true it waits for the opposite (default: false)
|
||||
* @uses utility/waitUntil, property/getValue
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
let waitForValue = function (selector, ms, reverse) {
|
||||
/**
|
||||
* we can't use default values for function parameter here because this would
|
||||
* break the ability to chain the command with an element if reverse is used, like
|
||||
*
|
||||
* ```js
|
||||
* var elem = $('#elem');
|
||||
* elem.waitForXXX(10000, true);
|
||||
* ```
|
||||
*/
|
||||
reverse = typeof reverse === 'boolean' ? reverse : false
|
||||
|
||||
/*!
|
||||
* ensure that ms is set properly
|
||||
*/
|
||||
if (typeof ms !== 'number') {
|
||||
ms = this.options.waitforTimeout
|
||||
}
|
||||
|
||||
const isReversed = reverse ? 'with' : 'without'
|
||||
const errorMsg = `element ("${selector || this.lastResult.selector}") still ${isReversed} a value after ${ms}ms`
|
||||
|
||||
return this.waitUntil(() => {
|
||||
return this.getValue(selector).then((value) => {
|
||||
if (!Array.isArray(value)) {
|
||||
return (value !== '') !== reverse
|
||||
}
|
||||
|
||||
let result = reverse
|
||||
for (let val of value) {
|
||||
if (!reverse) {
|
||||
result = result || val !== ''
|
||||
} else {
|
||||
result = result && val === ''
|
||||
}
|
||||
}
|
||||
|
||||
return result !== reverse
|
||||
})
|
||||
}, ms, errorMsg)
|
||||
}
|
||||
|
||||
export default waitForValue
|
||||
78
static/js/ketcher2/node_modules/webdriverio/lib/commands/waitForVisible.js
generated
vendored
Normal file
78
static/js/ketcher2/node_modules/webdriverio/lib/commands/waitForVisible.js
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
/**
|
||||
*
|
||||
* Wait for an element (selected by css selector) for the provided amount of
|
||||
* milliseconds to be (in)visible. If multiple elements get queryied by given
|
||||
* selector, it returns true (or false if reverse flag is set) if at least one
|
||||
* element is visible.
|
||||
*
|
||||
* <example>
|
||||
:index.html
|
||||
<div id="elem" style="visibility: hidden;">Hello World!</div>
|
||||
<script type="text/javascript">
|
||||
setTimeout(function () {
|
||||
document.getElementById('elem').style.visibility = 'visible';
|
||||
}, 2000);
|
||||
</script>
|
||||
|
||||
:waitForVisibleExample.js
|
||||
it('should detect when element is visible', function () {
|
||||
browser.waitForVisible('#elem', 3000);
|
||||
|
||||
// same as
|
||||
elem = $('#elem');
|
||||
elem.waitForVisible(3000)
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @alias browser.waitForVisible
|
||||
* @param {String} selector element to wait for
|
||||
* @param {Number=} ms time in ms (default: 500)
|
||||
* @param {Boolean=} reverse if true it waits for the opposite (default: false)
|
||||
* @uses utility/waitUntil, state/isVisible
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
let waitForVisible = function (selector, ms, reverse) {
|
||||
/**
|
||||
* we can't use default values for function parameter here because this would
|
||||
* break the ability to chain the command with an element if reverse is used, like
|
||||
*
|
||||
* ```js
|
||||
* var elem = $('#elem');
|
||||
* elem.waitForXXX(10000, true);
|
||||
* ```
|
||||
*/
|
||||
reverse = typeof reverse === 'boolean' ? reverse : false
|
||||
|
||||
/*!
|
||||
* ensure that ms is set properly
|
||||
*/
|
||||
if (typeof ms !== 'number') {
|
||||
ms = this.options.waitforTimeout
|
||||
}
|
||||
|
||||
const isReversed = reverse ? '' : 'not'
|
||||
const errorMsg = `element ("${selector || this.lastResult.selector}") still ${isReversed} visible after ${ms}ms`
|
||||
|
||||
return this.waitUntil(() => {
|
||||
return this.isVisible(selector).then((isVisible) => {
|
||||
if (!Array.isArray(isVisible)) {
|
||||
return isVisible !== reverse
|
||||
}
|
||||
|
||||
let result = reverse
|
||||
for (let val of isVisible) {
|
||||
if (!reverse) {
|
||||
result = result || val
|
||||
} else {
|
||||
result = result && val
|
||||
}
|
||||
}
|
||||
|
||||
return result !== reverse
|
||||
})
|
||||
}, ms, errorMsg)
|
||||
}
|
||||
|
||||
export default waitForVisible
|
||||
75
static/js/ketcher2/node_modules/webdriverio/lib/commands/waitUntil.js
generated
vendored
Normal file
75
static/js/ketcher2/node_modules/webdriverio/lib/commands/waitUntil.js
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
/**
|
||||
*
|
||||
* This wait command is your universal weapon if you want to wait on something. It expects a condition
|
||||
* and waits until that condition is fulfilled with a truthy value. A condition can be either a promise
|
||||
* or a command result. The commands within the condition are getting executed synchronously like in
|
||||
* your test.
|
||||
*
|
||||
* A common example is to wait until a certain element contains a certain text (see example).
|
||||
*
|
||||
* <example>
|
||||
:example.html
|
||||
<div id="someText">I am some text</div>
|
||||
<script>
|
||||
setTimeout(function() {
|
||||
$('#someText').html('I am now different');
|
||||
}, 1000);
|
||||
</script>
|
||||
|
||||
:waitUntil.js
|
||||
it('should wait until text has changed', function () {
|
||||
browser.waitUntil(function () {
|
||||
return browser.getText('#someText') === 'I am now different'
|
||||
}, 5000, 'expected text to be different after 5s');
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
*
|
||||
* @alias browser.waitUntil
|
||||
* @param {Function|Promise} condition condition to wait on
|
||||
* @param {Number=} timeout timeout in ms (default: 500)
|
||||
* @param {String=} timeoutMsg error message to throw when waitUntil times out
|
||||
* @param {Number=} interval interval between condition checks (default: 500)
|
||||
* @uses utility/pause
|
||||
* @type utility
|
||||
*
|
||||
*/
|
||||
|
||||
import { WaitUntilTimeoutError } from '../utils/ErrorHandler'
|
||||
import Timer from '../utils/Timer'
|
||||
|
||||
export default function (condition, timeout, timeoutMsg, interval) {
|
||||
/*!
|
||||
* ensure that timeout and interval are set properly
|
||||
*/
|
||||
if (typeof timeout !== 'number') {
|
||||
timeout = this.options.waitforTimeout
|
||||
}
|
||||
|
||||
if (typeof interval !== 'number') {
|
||||
interval = this.options.waitforInterval
|
||||
}
|
||||
|
||||
let fn
|
||||
|
||||
if (typeof condition === 'function') {
|
||||
fn = condition.bind(this)
|
||||
} else {
|
||||
fn = () => Promise.resolve(condition)
|
||||
}
|
||||
|
||||
let isSync = this.options.sync
|
||||
let timer = new Timer(interval, timeout, fn, true, isSync)
|
||||
|
||||
return timer.catch((e) => {
|
||||
if (e.message === 'timeout' && typeof timeoutMsg === 'string') {
|
||||
throw new WaitUntilTimeoutError(timeoutMsg)
|
||||
}
|
||||
|
||||
if (e.type === 'NoSuchElement') {
|
||||
throw new WaitUntilTimeoutError(e.message)
|
||||
}
|
||||
|
||||
throw new WaitUntilTimeoutError(`Promise was rejected with the following reason: ${e.message}`)
|
||||
})
|
||||
}
|
||||
40
static/js/ketcher2/node_modules/webdriverio/lib/protocol/alertAccept.js
generated
vendored
Normal file
40
static/js/ketcher2/node_modules/webdriverio/lib/protocol/alertAccept.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
*
|
||||
* Accepts the currently displayed alert dialog. Usually, this is equivalent to
|
||||
* clicking on the 'OK' button in the dialog.
|
||||
*
|
||||
* <example>
|
||||
:alertAccept.js
|
||||
it('demonstrate the alertAccept command', function () {
|
||||
if (browser.alertText()) {
|
||||
browser.alertAccept();
|
||||
}
|
||||
// ...
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @throws {RuntimeError} If no alert is present. The seleniumStack.type parameter will equal 'NoAlertOpenError'.
|
||||
*
|
||||
* @see https://w3c.github.io/webdriver/webdriver-spec.html#accept-alert
|
||||
* @type protocol
|
||||
*
|
||||
*/
|
||||
|
||||
export default function alertAccept () {
|
||||
const requestOptions = {
|
||||
path: '/session/:sessionId/accept_alert',
|
||||
method: 'POST'
|
||||
}
|
||||
|
||||
return this.requestHandler.create(requestOptions).catch((err) => {
|
||||
/**
|
||||
* jsonwire command not supported try webdriver endpoint
|
||||
*/
|
||||
if (err.message.match(/did not match a known command/)) {
|
||||
requestOptions.path = '/session/:sessionId/alert/accept'
|
||||
return this.requestHandler.create(requestOptions)
|
||||
}
|
||||
|
||||
throw err
|
||||
})
|
||||
}
|
||||
41
static/js/ketcher2/node_modules/webdriverio/lib/protocol/alertDismiss.js
generated
vendored
Normal file
41
static/js/ketcher2/node_modules/webdriverio/lib/protocol/alertDismiss.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
*
|
||||
* Dismisses the currently displayed alert dialog. For confirm() and prompt()
|
||||
* dialogs, this is equivalent to clicking the 'Cancel' button. For alert()
|
||||
* dialogs, this is equivalent to clicking the 'OK' button.
|
||||
*
|
||||
* <example>
|
||||
:alertAccept.js
|
||||
it('demonstrate the alertDismiss command', function () {
|
||||
if (browser.alertText()) {
|
||||
browser.alertDismiss();
|
||||
}
|
||||
// ...
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @throws {RuntimeError} If no alert is present. The seleniumStack.type parameter will equal 'NoAlertOpenError'.
|
||||
*
|
||||
* @see https://w3c.github.io/webdriver/webdriver-spec.html#dismiss-alert
|
||||
* @type protocol
|
||||
*
|
||||
*/
|
||||
|
||||
export default function alertDismiss () {
|
||||
const requestOptions = {
|
||||
path: '/session/:sessionId/dismiss_alert',
|
||||
method: 'POST'
|
||||
}
|
||||
|
||||
return this.requestHandler.create(requestOptions).catch((err) => {
|
||||
/**
|
||||
* jsonwire command not supported try webdriver endpoint
|
||||
*/
|
||||
if (err.message.match(/did not match a known command/)) {
|
||||
requestOptions.path = '/session/:sessionId/alert/dismiss'
|
||||
return this.requestHandler.create(requestOptions)
|
||||
}
|
||||
|
||||
throw err
|
||||
})
|
||||
}
|
||||
54
static/js/ketcher2/node_modules/webdriverio/lib/protocol/alertText.js
generated
vendored
Normal file
54
static/js/ketcher2/node_modules/webdriverio/lib/protocol/alertText.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
*
|
||||
* Gets the text of the currently displayed JavaScript alert(), confirm(), or prompt() dialog.
|
||||
*
|
||||
* <example>
|
||||
:alertText.js
|
||||
it('demonstrate the alertDismiss command', function () {
|
||||
if (browser.alertText()) {
|
||||
browser.alertDismiss();
|
||||
}
|
||||
// ...
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @param {String=} text Keystrokes to send to the prompt() dialog.
|
||||
* @return {String} The text of the currently displayed alert.
|
||||
* @throws {RuntimeError} If no alert is present. The seleniumStack.type parameter will equal 'NoAlertOpenError'.
|
||||
*
|
||||
* @see https://w3c.github.io/webdriver/webdriver-spec.html#get-alert-text
|
||||
* @see https://w3c.github.io/webdriver/webdriver-spec.html#send-alert-text
|
||||
* @type protocol
|
||||
*
|
||||
*/
|
||||
|
||||
let alertText = function (text) {
|
||||
const requestOptions = {
|
||||
path: '/session/:sessionId/alert_text',
|
||||
method: 'GET'
|
||||
}
|
||||
const data = {}
|
||||
|
||||
if (typeof text === 'string') {
|
||||
requestOptions.method = 'POST'
|
||||
data.text = text
|
||||
}
|
||||
|
||||
const request = this.requestHandler.create(requestOptions, data).catch((err) => {
|
||||
/**
|
||||
* jsonwire command not supported try webdriver endpoint
|
||||
*/
|
||||
if (err.message.match(/did not match a known command/)) {
|
||||
requestOptions.path = '/session/:sessionId/alert/text'
|
||||
return this.requestHandler.create(requestOptions, data)
|
||||
}
|
||||
|
||||
throw err
|
||||
})
|
||||
|
||||
return this.unify(request, {
|
||||
extractValue: true
|
||||
})
|
||||
}
|
||||
|
||||
export default alertText
|
||||
20
static/js/ketcher2/node_modules/webdriverio/lib/protocol/applicationCacheStatus.js
generated
vendored
Normal file
20
static/js/ketcher2/node_modules/webdriverio/lib/protocol/applicationCacheStatus.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
*
|
||||
* Get the status of the html5 application cache.
|
||||
*
|
||||
* This command is depcrecated and will be removed soon. Make sure you don't use it in your
|
||||
* automation/test scripts anymore to avoid errors.
|
||||
*
|
||||
* @return {Number} Status code for application cache: **{UNCACHED = 0, IDLE = 1, CHECKING = 2, DOWNLOADING = 3, UPDATE_READY = 4, OBSOLETE = 5}**
|
||||
*
|
||||
* @see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidapplication_cachestatus
|
||||
* @type protocol
|
||||
*
|
||||
*/
|
||||
|
||||
import depcrecate from '../helpers/depcrecationWarning'
|
||||
|
||||
export default function applicationCacheStatus () {
|
||||
depcrecate('applicationCacheStatus')
|
||||
return this.requestHandler.create('/session/:sessionId/application_cache/status')
|
||||
}
|
||||
24
static/js/ketcher2/node_modules/webdriverio/lib/protocol/back.js
generated
vendored
Normal file
24
static/js/ketcher2/node_modules/webdriverio/lib/protocol/back.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
*
|
||||
* Navigate backwards in the browser history, if possible.
|
||||
*
|
||||
* @see https://w3c.github.io/webdriver/webdriver-spec.html#back
|
||||
* @type protocol
|
||||
*
|
||||
*/
|
||||
|
||||
export default function back () {
|
||||
if (this.desiredCapabilities.browserName === 'safari') {
|
||||
/*!
|
||||
* helper for safaridriver which doesn not support forward
|
||||
* Reason: "Yikes! Safari history navigation does not work. We can go forward or back,
|
||||
* but once we do, we can no longer communicate with the page"
|
||||
*/
|
||||
return this.execute('history.go(-1)')
|
||||
}
|
||||
|
||||
return this.requestHandler.create({
|
||||
path: '/session/:sessionId/back',
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
23
static/js/ketcher2/node_modules/webdriverio/lib/protocol/background.js
generated
vendored
Normal file
23
static/js/ketcher2/node_modules/webdriverio/lib/protocol/background.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
*
|
||||
* Send the currently active app to the background.
|
||||
*
|
||||
* <example>
|
||||
:backgroundApp.js
|
||||
browser.background(1);
|
||||
* </example>
|
||||
*
|
||||
* @param {Number} seconds number of seconds after the app gets send to background
|
||||
*
|
||||
* @see https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/appium-bindings.md#background-app
|
||||
* @type mobile
|
||||
* @for android
|
||||
*
|
||||
*/
|
||||
|
||||
export default function background (seconds = 0) {
|
||||
return this.requestHandler.create({
|
||||
path: '/session/:sessionId/appium/app/background',
|
||||
method: 'POST'
|
||||
}, { seconds })
|
||||
}
|
||||
28
static/js/ketcher2/node_modules/webdriverio/lib/protocol/buttonDown.js
generated
vendored
Normal file
28
static/js/ketcher2/node_modules/webdriverio/lib/protocol/buttonDown.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
*
|
||||
* Click and hold the left mouse button (at the coordinates set by the last moveto
|
||||
* command). Note that the next mouse-related command that should follow is buttonup.
|
||||
* Any other mouse command (such as click or another call to buttondown) will yield
|
||||
* undefined behaviour.
|
||||
*
|
||||
* This command is depcrecated and will be removed soon. Make sure you don't use it in your
|
||||
* automation/test scripts anymore to avoid errors.
|
||||
*
|
||||
* @param {Number} button Which button, enum: *{LEFT = 0, MIDDLE = 1 , RIGHT = 2}*. Defaults to the left mouse button if not specified.
|
||||
*
|
||||
* @see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidbuttondown
|
||||
* @type protocol
|
||||
*
|
||||
*/
|
||||
|
||||
import handleMouseButtonProtocol from '../helpers/handleMouseButtonProtocol'
|
||||
import depcrecate from '../helpers/depcrecationWarning'
|
||||
|
||||
export default function buttonDown (button) {
|
||||
depcrecate('buttonDown')
|
||||
return handleMouseButtonProtocol.call(
|
||||
this,
|
||||
'/session/:sessionId/buttondown',
|
||||
button
|
||||
)
|
||||
}
|
||||
25
static/js/ketcher2/node_modules/webdriverio/lib/protocol/buttonPress.js
generated
vendored
Executable file
25
static/js/ketcher2/node_modules/webdriverio/lib/protocol/buttonPress.js
generated
vendored
Executable file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
*
|
||||
* Click any mouse button (at the coordinates set by the last moveto command). Note
|
||||
* that calling this command after calling buttondown and before calling button up
|
||||
* (or any out-of-order interactions sequence) will yield undefined behaviour.
|
||||
*
|
||||
* This command is depcrecated and will be removed soon. Make sure you don't use it in your
|
||||
* automation/test scripts anymore to avoid errors.
|
||||
*
|
||||
* @param {Number} button Which button, enum: *{LEFT = 0, MIDDLE = 1 , RIGHT = 2}*. Defaults to the left mouse button if not specified.
|
||||
* @type protocol
|
||||
*
|
||||
*/
|
||||
|
||||
import handleMouseButtonProtocol from '../helpers/handleMouseButtonProtocol'
|
||||
import depcrecate from '../helpers/depcrecationWarning'
|
||||
|
||||
export default function buttonPress (button) {
|
||||
depcrecate('buttonPress')
|
||||
return handleMouseButtonProtocol.call(
|
||||
this,
|
||||
'/session/:sessionId/click',
|
||||
button
|
||||
)
|
||||
}
|
||||
27
static/js/ketcher2/node_modules/webdriverio/lib/protocol/buttonUp.js
generated
vendored
Normal file
27
static/js/ketcher2/node_modules/webdriverio/lib/protocol/buttonUp.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
*
|
||||
* Releases the mouse button previously held (where the mouse is currently at). Must
|
||||
* be called once for every buttondown command issued. See the note in click and
|
||||
* buttondown about implications of out-of-order commands.
|
||||
*
|
||||
* This command is depcrecated and will be removed soon. Make sure you don't use it in your
|
||||
* automation/test scripts anymore to avoid errors.
|
||||
*
|
||||
* @param {Number} button Which button, enum: *{LEFT = 0, MIDDLE = 1 , RIGHT = 2}*. Defaults to the left mouse button if not specified.
|
||||
*
|
||||
* @see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidbuttonup
|
||||
* @type protocol
|
||||
*
|
||||
*/
|
||||
|
||||
import handleMouseButtonProtocol from '../helpers/handleMouseButtonProtocol'
|
||||
import depcrecate from '../helpers/depcrecationWarning'
|
||||
|
||||
export default function buttonUp (button) {
|
||||
depcrecate('buttonUp')
|
||||
return handleMouseButtonProtocol.call(
|
||||
this,
|
||||
'/session/:sessionId/buttonup',
|
||||
button
|
||||
)
|
||||
}
|
||||
21
static/js/ketcher2/node_modules/webdriverio/lib/protocol/closeApp.js
generated
vendored
Normal file
21
static/js/ketcher2/node_modules/webdriverio/lib/protocol/closeApp.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
*
|
||||
* Close the given application.
|
||||
*
|
||||
* <example>
|
||||
:closeApp.js
|
||||
browser.closeApp()
|
||||
* </example>
|
||||
*
|
||||
* @see https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/appium-bindings.md#close-app
|
||||
* @type mobile
|
||||
* @for ios
|
||||
*
|
||||
*/
|
||||
|
||||
export default function closeApp () {
|
||||
return this.requestHandler.create({
|
||||
path: '/session/:sessionId/appium/app/close',
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
30
static/js/ketcher2/node_modules/webdriverio/lib/protocol/context.js
generated
vendored
Normal file
30
static/js/ketcher2/node_modules/webdriverio/lib/protocol/context.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
*
|
||||
* Retrieve current context or switch to the specified context
|
||||
*
|
||||
* @param {String=} id the context to switch to
|
||||
*
|
||||
* @see http://appium.io/slate/en/v1.1.0/?javascript#automating-hybrid-ios-apps
|
||||
* @see https://github.com/admc/wd/blob/master/lib/commands.js#L279
|
||||
* @type mobile
|
||||
* @for android, ios
|
||||
*
|
||||
*/
|
||||
|
||||
import depcrecate from '../helpers/depcrecationWarning'
|
||||
|
||||
export default function context (id) {
|
||||
const data = {}
|
||||
const requestOptions = {
|
||||
path: '/session/:sessionId/context',
|
||||
method: 'GET'
|
||||
}
|
||||
|
||||
if (typeof id === 'string') {
|
||||
requestOptions.method = 'POST'
|
||||
data.name = id
|
||||
}
|
||||
|
||||
depcrecate('context')
|
||||
return this.requestHandler.create(requestOptions, data)
|
||||
}
|
||||
17
static/js/ketcher2/node_modules/webdriverio/lib/protocol/contexts.js
generated
vendored
Normal file
17
static/js/ketcher2/node_modules/webdriverio/lib/protocol/contexts.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
*
|
||||
* Returns an object with a value field containing the list of all available contexts
|
||||
*
|
||||
* @see http://appium.io/slate/en/v1.1.0/?javascript#automating-hybrid-ios-apps
|
||||
* @see https://github.com/admc/wd/blob/master/lib/commands.js#L279
|
||||
* @type mobile
|
||||
* @for android, ios
|
||||
*
|
||||
*/
|
||||
|
||||
import depcrecate from '../helpers/depcrecationWarning'
|
||||
|
||||
export default function contexts () {
|
||||
depcrecate('contexts')
|
||||
return this.requestHandler.create('/session/:sessionId/contexts')
|
||||
}
|
||||
54
static/js/ketcher2/node_modules/webdriverio/lib/protocol/cookie.js
generated
vendored
Normal file
54
static/js/ketcher2/node_modules/webdriverio/lib/protocol/cookie.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Protocol binding to operate with cookies on the current page.
|
||||
*
|
||||
* <example>
|
||||
:cookie.js
|
||||
it('should get/set cookies using protocol command', function () {
|
||||
// get all cookies
|
||||
var cookies = browser.cookie();
|
||||
console.log(cookies); // outputs: [{ name: 'test', value: '123' }]
|
||||
|
||||
// set cookie
|
||||
browser.cookie('post', {
|
||||
name: 'myCookie',
|
||||
value: 'some content'
|
||||
});
|
||||
|
||||
// delete cookie (sync)
|
||||
browser.cookie('delete','myCookie');
|
||||
})
|
||||
* </example>
|
||||
*
|
||||
* @param {String=} method request method
|
||||
* @param {Object=|String=} args contains cookie information if you want to set a cookie or contains name of cookie if you want to delete it
|
||||
*
|
||||
* @return {Object} cookie data
|
||||
*
|
||||
* @see https://w3c.github.io/webdriver/webdriver-spec.html#cookies
|
||||
* @type protocol
|
||||
*
|
||||
*/
|
||||
|
||||
export default function cookie (method = 'GET', args) {
|
||||
const data = {}
|
||||
const requestOptions = {
|
||||
path: '/session/:sessionId/cookie',
|
||||
method: method
|
||||
}
|
||||
|
||||
/**
|
||||
* set cookie param for POST method
|
||||
*/
|
||||
if (method.toUpperCase() === 'POST' && typeof args === 'object') {
|
||||
data.cookie = args
|
||||
}
|
||||
|
||||
/**
|
||||
* add cookie name tp path URL to delete a specific cookie object
|
||||
*/
|
||||
if (method.toUpperCase() === 'DELETE' && typeof args === 'string') {
|
||||
requestOptions.path += '/' + args
|
||||
}
|
||||
|
||||
return this.requestHandler.create(requestOptions, data)
|
||||
}
|
||||
21
static/js/ketcher2/node_modules/webdriverio/lib/protocol/currentActivity.js
generated
vendored
Normal file
21
static/js/ketcher2/node_modules/webdriverio/lib/protocol/currentActivity.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
*
|
||||
* Receive the current activity on an Android device.
|
||||
*
|
||||
* <example>
|
||||
:rotateAsync.js
|
||||
it('should get the activity of the android device', function () {
|
||||
var activity = browser.currentActivity()
|
||||
console.log(activity); // returns android activity information
|
||||
});
|
||||
* </example>
|
||||
*
|
||||
* @see https://github.com/appium/appium-android-driver/blob/master/lib/commands/general.js#L59-L61
|
||||
* @type mobile
|
||||
* @for android
|
||||
*
|
||||
*/
|
||||
|
||||
export default function currentActivity () {
|
||||
return this.requestHandler.create('/session/:sessionId/appium/device/current_activity')
|
||||
}
|
||||
28
static/js/ketcher2/node_modules/webdriverio/lib/protocol/deviceKeyEvent.js
generated
vendored
Normal file
28
static/js/ketcher2/node_modules/webdriverio/lib/protocol/deviceKeyEvent.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
*
|
||||
* send a key event to the device
|
||||
*
|
||||
* @param {Number} keyValue device specifc key value
|
||||
*
|
||||
* @see https://github.com/appium/appium/blob/master/docs/en/appium-bindings.md#key-event
|
||||
* @type mobile
|
||||
* @for android
|
||||
*
|
||||
*/
|
||||
|
||||
export default function deviceKeyEvent (keycode, metastate) {
|
||||
let data = {
|
||||
keycode: keycode
|
||||
}
|
||||
|
||||
if (metastate) {
|
||||
data.metastate = metastate
|
||||
}
|
||||
|
||||
let requestOptions = {
|
||||
path: '/session/:sessionId/appium/device/keyevent',
|
||||
method: 'POST'
|
||||
}
|
||||
|
||||
return this.requestHandler.create(requestOptions, data)
|
||||
}
|
||||
21
static/js/ketcher2/node_modules/webdriverio/lib/protocol/doDoubleClick.js
generated
vendored
Normal file
21
static/js/ketcher2/node_modules/webdriverio/lib/protocol/doDoubleClick.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
*
|
||||
* Double-clicks at the current mouse coordinates (set by moveto.
|
||||
*
|
||||
* This command is depcrecated and will be removed soon. Make sure you don't use it in your
|
||||
* automation/test scripts anymore to avoid errors.
|
||||
*
|
||||
* @see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessioniddoubleclick
|
||||
* @type protocol
|
||||
*
|
||||
*/
|
||||
|
||||
import depcrecate from '../helpers/depcrecationWarning'
|
||||
|
||||
export default function doDoubleClick () {
|
||||
depcrecate('doDoubleClick')
|
||||
return this.requestHandler.create({
|
||||
path: '/session/:sessionId/doubleclick',
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
80
static/js/ketcher2/node_modules/webdriverio/lib/protocol/element.js
generated
vendored
Normal file
80
static/js/ketcher2/node_modules/webdriverio/lib/protocol/element.js
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
/**
|
||||
* Search for an element on the page, starting from the document root.
|
||||
* The located element will be returned as a WebElement JSON object.
|
||||
* The table below lists the locator strategies that each server should support.
|
||||
* Each locator must return the first matching element located in the DOM.
|
||||
*
|
||||
* @see https://w3c.github.io/webdriver/webdriver-spec.html#find-element
|
||||
*
|
||||
* @param {String} selector selector to query the element
|
||||
* @return {String} A WebElement JSON object for the located element.
|
||||
*
|
||||
* @type protocol
|
||||
*
|
||||
*/
|
||||
|
||||
import findStrategy from '../helpers/findElementStrategy'
|
||||
import hasElementResult from '../helpers/hasElementResultHelper'
|
||||
import q from 'q'
|
||||
|
||||
export default function element (selector) {
|
||||
let requestPath = '/session/:sessionId/element'
|
||||
let lastPromise = this.lastResult ? q(this.lastResult).inspect() : this.lastPromise.inspect()
|
||||
let relative = false
|
||||
|
||||
if (lastPromise.state === 'fulfilled' && hasElementResult(lastPromise.value) === 1) {
|
||||
if (!selector) {
|
||||
return lastPromise.value
|
||||
}
|
||||
|
||||
/**
|
||||
* format xpath selector (global -> relative)
|
||||
*/
|
||||
if (selector.slice(0, 2) === '//') {
|
||||
selector = '.' + selector.slice(1)
|
||||
}
|
||||
|
||||
let elem = lastPromise.value.value.ELEMENT
|
||||
relative = true
|
||||
requestPath = `/session/:sessionId/element/${elem}/element`
|
||||
}
|
||||
|
||||
let found = findStrategy(selector, relative)
|
||||
return this.requestHandler.create(
|
||||
requestPath,
|
||||
{ using: found.using, value: found.value }
|
||||
).then((result) => {
|
||||
result.selector = selector
|
||||
|
||||
/**
|
||||
* W3C webdriver protocol has changed element identifier from `ELEMENT` to
|
||||
* `element-6066-11e4-a52e-4f735466cecf`. Let's make sure both identifier
|
||||
* are supported.
|
||||
*/
|
||||
const elemValue = result.value.ELEMENT || result.value['element-6066-11e4-a52e-4f735466cecf']
|
||||
if (elemValue) {
|
||||
result.value = {
|
||||
ELEMENT: elemValue,
|
||||
'element-6066-11e4-a52e-4f735466cecf': elemValue
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}, (e) => {
|
||||
let result = e.seleniumStack
|
||||
|
||||
/**
|
||||
* if error is not NoSuchElement throw it
|
||||
*/
|
||||
if (!result || result.type !== 'NoSuchElement') {
|
||||
throw e
|
||||
}
|
||||
|
||||
result.state = 'failure'
|
||||
result.sessionId = this.requestHandler.sessionID
|
||||
result.value = null
|
||||
result.selector = selector
|
||||
delete result.orgStatusMessage
|
||||
return result
|
||||
})
|
||||
}
|
||||
29
static/js/ketcher2/node_modules/webdriverio/lib/protocol/elementActive.js
generated
vendored
Normal file
29
static/js/ketcher2/node_modules/webdriverio/lib/protocol/elementActive.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
*
|
||||
* Get the element on the page that currently has focus. The element will be returned as a WebElement JSON object.
|
||||
*
|
||||
* @return {String} A WebElement JSON object for the active element.
|
||||
*
|
||||
* @see https://w3c.github.io/webdriver/webdriver-spec.html#get-active-element
|
||||
* @type protocol
|
||||
*
|
||||
*/
|
||||
|
||||
export default function elementActive () {
|
||||
const requestOptions = {
|
||||
path: '/session/:sessionId/element/active',
|
||||
method: 'POST'
|
||||
}
|
||||
|
||||
return this.requestHandler.create(requestOptions).catch((err) => {
|
||||
/**
|
||||
* jsonwire command not supported try webdriver endpoint
|
||||
*/
|
||||
if (err.message.match(/did not match a known command/)) {
|
||||
requestOptions.method = 'GET'
|
||||
return this.requestHandler.create(requestOptions)
|
||||
}
|
||||
|
||||
throw err
|
||||
})
|
||||
}
|
||||
23
static/js/ketcher2/node_modules/webdriverio/lib/protocol/elementIdAttribute.js
generated
vendored
Normal file
23
static/js/ketcher2/node_modules/webdriverio/lib/protocol/elementIdAttribute.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
*
|
||||
* Get the value of an element's attribute.
|
||||
*
|
||||
* @param {String} ID ID of a WebElement JSON object to route the command to
|
||||
* @param {String} attributeName attribute name of element you want to receive
|
||||
*
|
||||
* @return {String|null} The value of the attribute, or null if it is not set on the element.
|
||||
*
|
||||
* @see https://w3c.github.io/webdriver/webdriver-spec.html#dfn-get-element-attribute
|
||||
* @type protocol
|
||||
*
|
||||
*/
|
||||
|
||||
import { ProtocolError } from '../utils/ErrorHandler'
|
||||
|
||||
export default function elementIdAttribute (id, attributeName) {
|
||||
if ((typeof id !== 'string' && typeof id !== 'number') || typeof attributeName !== 'string') {
|
||||
throw new ProtocolError('number or type of arguments don\'t agree with elementIdAttribute protocol command')
|
||||
}
|
||||
|
||||
return this.requestHandler.create(`/session/:sessionId/element/${id}/attribute/${attributeName}`)
|
||||
}
|
||||
23
static/js/ketcher2/node_modules/webdriverio/lib/protocol/elementIdClear.js
generated
vendored
Normal file
23
static/js/ketcher2/node_modules/webdriverio/lib/protocol/elementIdClear.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
*
|
||||
* Clear a `TEXTAREA` or text `INPUT element's value.
|
||||
*
|
||||
* @param {String} ID ID of a WebElement JSON object to route the command to
|
||||
*
|
||||
* @see https://w3c.github.io/webdriver/webdriver-spec.html#dfn-element-clear
|
||||
* @type protocol
|
||||
*
|
||||
*/
|
||||
|
||||
import { ProtocolError } from '../utils/ErrorHandler'
|
||||
|
||||
export default function elementIdClear (id) {
|
||||
if (typeof id !== 'string' && typeof id !== 'number') {
|
||||
throw new ProtocolError('number or type of arguments don\'t agree with elementIdClear protocol command')
|
||||
}
|
||||
|
||||
return this.requestHandler.create({
|
||||
path: `/session/:sessionId/element/${id}/clear`,
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user