minigame
This commit is contained in:
45
node_modules/selenium-webdriver/example/chrome_android.js
generated
vendored
Normal file
45
node_modules/selenium-webdriver/example/chrome_android.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The SFC licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview A basic example of working with Chrome on Android. Before
|
||||
* running this example, you must start adb and connect a device (or start an
|
||||
* AVD).
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const { Builder, By, Key, until } = require('..')
|
||||
const { Options } = require('../chrome')
|
||||
|
||||
;(async function () {
|
||||
let driver
|
||||
try {
|
||||
driver = await new Builder()
|
||||
.forBrowser('chrome')
|
||||
.setChromeOptions(new Options().androidChrome())
|
||||
.build()
|
||||
await driver.get('http://www.google.com/ncr')
|
||||
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
|
||||
await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
|
||||
} finally {
|
||||
;(await driver) && driver.quit()
|
||||
}
|
||||
})().then(
|
||||
(_) => console.log('SUCCESS'),
|
||||
(err) => console.error('ERROR: ' + err)
|
||||
)
|
||||
46
node_modules/selenium-webdriver/example/chrome_mobile_emulation.js
generated
vendored
Normal file
46
node_modules/selenium-webdriver/example/chrome_mobile_emulation.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
// Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The SFC licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview This is an example of emulating a mobile device using the
|
||||
* ChromeDriver.
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const { Builder, By, Key, until } = require('..')
|
||||
const { Options } = require('../chrome')
|
||||
|
||||
;(async function () {
|
||||
let driver
|
||||
try {
|
||||
driver = await new Builder()
|
||||
.forBrowser('chrome')
|
||||
.setChromeOptions(
|
||||
new Options().setMobileEmulation({ deviceName: 'Nexus 5X' })
|
||||
)
|
||||
.build()
|
||||
await driver.get('http://www.google.com/ncr')
|
||||
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
|
||||
await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
|
||||
} finally {
|
||||
;(await driver) && driver.quit()
|
||||
}
|
||||
})().then(
|
||||
(_) => console.log('SUCCESS'),
|
||||
(err) => console.error('ERROR: ' + err)
|
||||
)
|
||||
84
node_modules/selenium-webdriver/example/firefox_channels.js
generated
vendored
Normal file
84
node_modules/selenium-webdriver/example/firefox_channels.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
// Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The SFC licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview This is an example of working with the different Firefox
|
||||
* release channels. Before running this example, you will need to have
|
||||
* installed Firefox's release, nightly, and developer editions:
|
||||
*
|
||||
* - https://www.mozilla.org/en-US/firefox/channel/desktop/#aurora
|
||||
* - https://www.mozilla.org/en-US/firefox/channel/desktop/#nightly
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const { Builder, By, Key, promise, until } = require('..')
|
||||
const { Channel, Options } = require('../firefox')
|
||||
|
||||
let i = 0
|
||||
function resposition(driver) {
|
||||
return driver
|
||||
.manage()
|
||||
.window()
|
||||
.setRect({
|
||||
width: 600,
|
||||
height: 400,
|
||||
x: 300 * i++,
|
||||
y: 0,
|
||||
})
|
||||
}
|
||||
|
||||
async function doSearch(driver) {
|
||||
try {
|
||||
// Start on the base about page.
|
||||
await driver.get('about:')
|
||||
// Reposition so users can see the three windows.
|
||||
await resposition(driver)
|
||||
// Pause so users can see the magic.
|
||||
await promise.delayed(750)
|
||||
// Now do the rest.
|
||||
await driver.get('http://www.google.com/ncr')
|
||||
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
|
||||
await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
|
||||
console.log('Success!')
|
||||
} catch (ex) {
|
||||
console.log('An error occured! ' + ex)
|
||||
} finally {
|
||||
await driver.quit()
|
||||
}
|
||||
}
|
||||
|
||||
function createDriver(channel) {
|
||||
let options = new Options().setBinary(channel)
|
||||
return new Builder().forBrowser('firefox').setFirefoxOptions(options).build()
|
||||
}
|
||||
|
||||
Promise.all([
|
||||
doSearch(createDriver(Channel.RELEASE)),
|
||||
doSearch(createDriver(Channel.AURORA)), // Developer Edition.
|
||||
doSearch(createDriver(Channel.NIGHTLY)),
|
||||
]).then(
|
||||
(_) => {
|
||||
console.log('All done!')
|
||||
},
|
||||
(err) => {
|
||||
console.error('An error occured! ' + err)
|
||||
setTimeout(() => {
|
||||
throw err
|
||||
}, 0)
|
||||
}
|
||||
)
|
||||
50
node_modules/selenium-webdriver/example/google_search.js
generated
vendored
Normal file
50
node_modules/selenium-webdriver/example/google_search.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
// Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The SFC licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview An example WebDriver script.
|
||||
*
|
||||
* Before running this script, ensure that Mozilla's geckodriver is present on
|
||||
* your system PATH: <https://github.com/mozilla/geckodriver/releases>
|
||||
*
|
||||
* Usage:
|
||||
* // Default behavior
|
||||
* node selenium-webdriver/example/google_search.js
|
||||
*
|
||||
* // Target Chrome locally; the chromedriver must be on your PATH
|
||||
* SELENIUM_BROWSER=chrome node selenium-webdriver/example/google_search.js
|
||||
*
|
||||
* // Use a local copy of the standalone Selenium server
|
||||
* SELENIUM_SERVER_JAR=/path/to/selenium-server-standalone.jar \
|
||||
* node selenium-webdriver/example/google_search.js
|
||||
*
|
||||
* // Target a remote Selenium server
|
||||
* SELENIUM_REMOTE_URL=http://www.example.com:4444/wd/hub \
|
||||
* node selenium-webdriver/example/google_search.js
|
||||
*/
|
||||
|
||||
const { Builder, By, Key, until } = require('..')
|
||||
|
||||
const driver = new Builder().forBrowser('firefox').build()
|
||||
|
||||
driver
|
||||
.get('http://www.google.com/ncr')
|
||||
.then((_) =>
|
||||
driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
|
||||
)
|
||||
.then((_) => driver.wait(until.titleIs('webdriver - Google Search'), 1000))
|
||||
.then((_) => driver.quit())
|
||||
70
node_modules/selenium-webdriver/example/google_search_test.js
generated
vendored
Normal file
70
node_modules/selenium-webdriver/example/google_search_test.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
// Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The SFC licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview An example test that may be run using Mocha.
|
||||
*
|
||||
* This example uses the `selenium-webdriver/testing.suite` function, which will
|
||||
* automatically run tests against every available WebDriver browser on the
|
||||
* current system. Alternatively, you may use the `SELENIUM_BROWSER`
|
||||
* environment variable to narrow the scope at runtime.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* # Automatically determine which browsers to run against.
|
||||
* mocha -t 10000 selenium-webdriver/example/google_search_test.js
|
||||
*
|
||||
* # Configure tests to only run against Google Chrome.
|
||||
* SELENIUM_BROWSER=chrome \
|
||||
* mocha -t 10000 selenium-webdriver/example/google_search_test.js
|
||||
*/
|
||||
|
||||
const { Browser, By, Key, until } = require('..')
|
||||
const { ignore, suite } = require('../testing')
|
||||
|
||||
suite(function (env) {
|
||||
describe('Google Search', function () {
|
||||
let driver
|
||||
|
||||
before(async function () {
|
||||
// env.builder() returns a Builder instance preconfigured for the
|
||||
// envrionment's target browser (you may still define browser specific
|
||||
// options if necessary (i.e. firefox.Options or chrome.Options)).
|
||||
driver = await env.builder().build()
|
||||
})
|
||||
|
||||
it('demo', async function () {
|
||||
await driver.get('https://www.google.com/ncr')
|
||||
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
|
||||
await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
|
||||
})
|
||||
|
||||
// The ignore function returns wrappers around describe & it that will
|
||||
// suppress tests if the provided predicate returns true. You may provide
|
||||
// any synchronous predicate. The env.browsers(...) function generates a
|
||||
// predicate that will suppress tests if the env targets one of the
|
||||
// specified browsers.
|
||||
//
|
||||
// This example is always configured to skip Chrome.
|
||||
ignore(env.browsers(Browser.CHROME)).it('demo 2', async function () {
|
||||
await driver.get('https://www.google.com/ncr')
|
||||
await driver.wait(until.urlIs('https://www.google.com/'), 1500)
|
||||
})
|
||||
|
||||
after(() => driver && driver.quit())
|
||||
})
|
||||
})
|
||||
63
node_modules/selenium-webdriver/example/headless.js
generated
vendored
Normal file
63
node_modules/selenium-webdriver/example/headless.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The SFC licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview An example of running Chrome or Firefox in headless mode.
|
||||
*
|
||||
* To run with Chrome, ensure you have Chrome 59+ installed and that
|
||||
* chromedriver 2.30+ is present on your system PATH:
|
||||
* <https://chromedriver.chromium.org/downloads>
|
||||
*
|
||||
* SELENIUM_BROWSER=chrome node selenium-webdriver/example/headless.js
|
||||
*
|
||||
* To run with Firefox, ensure you have Firefox 57+ installed and that
|
||||
* geckodriver 0.19.0+ is present on your system PATH:
|
||||
* <https://github.com/mozilla/geckodriver/releases>
|
||||
*
|
||||
* SELENIUM_BROWSER=firefox node selenium-webdriver/example/headless.js
|
||||
*/
|
||||
|
||||
const chrome = require('../chrome')
|
||||
const firefox = require('../firefox')
|
||||
const { Builder, By, Key, until } = require('..')
|
||||
|
||||
const width = 640
|
||||
const height = 480
|
||||
|
||||
let driver = new Builder()
|
||||
.forBrowser('chrome')
|
||||
.setChromeOptions(
|
||||
new chrome.Options().headless().windowSize({ width, height })
|
||||
)
|
||||
.setFirefoxOptions(
|
||||
new firefox.Options().headless().windowSize({ width, height })
|
||||
)
|
||||
.build()
|
||||
|
||||
driver
|
||||
.get('http://www.google.com/ncr')
|
||||
.then((_) =>
|
||||
driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
|
||||
)
|
||||
.then((_) => driver.wait(until.titleIs('webdriver - Google Search'), 1000))
|
||||
.then(
|
||||
(_) => driver.quit(),
|
||||
(e) =>
|
||||
driver.quit().then(() => {
|
||||
throw e
|
||||
})
|
||||
)
|
||||
64
node_modules/selenium-webdriver/example/logging.js
generated
vendored
Normal file
64
node_modules/selenium-webdriver/example/logging.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
// Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The SFC licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Demonstrates how to use WebDriver's logging sysem.
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const chrome = require('../chrome')
|
||||
const firefox = require('../firefox')
|
||||
const edge = require('../edge')
|
||||
const { Builder, By, Key, logging, until } = require('..')
|
||||
|
||||
logging.installConsoleHandler()
|
||||
logging.getLogger('webdriver.http').setLevel(logging.Level.ALL)
|
||||
;(async function () {
|
||||
let driver
|
||||
try {
|
||||
driver = await new Builder()
|
||||
// Default to using Firefox. This can be overridden at runtime by
|
||||
// setting the SELENIUM_BROWSER environment variable:
|
||||
//
|
||||
// SELENIUM_BROWSER=chrome node selenium-webdriver/example/logging.js
|
||||
.forBrowser('firefox')
|
||||
// Configure the service for each browser to enable verbose logging and
|
||||
// to inherit the stdio settings from the current process. The builder
|
||||
// will only start the service if needed for the selected browser.
|
||||
.setChromeService(
|
||||
new chrome.ServiceBuilder().enableVerboseLogging().setStdio('inherit')
|
||||
)
|
||||
.setEdgeService(
|
||||
process.platform === 'win32'
|
||||
? new edge.ServiceBuilder().enableVerboseLogging().setStdio('inherit')
|
||||
: null
|
||||
)
|
||||
.setFirefoxService(
|
||||
new firefox.ServiceBuilder().enableVerboseLogging().setStdio('inherit')
|
||||
)
|
||||
.build()
|
||||
|
||||
await driver.get('http://www.google.com/ncr')
|
||||
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
|
||||
await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
|
||||
} finally {
|
||||
if (driver) {
|
||||
await driver.quit()
|
||||
}
|
||||
}
|
||||
})()
|
||||
Reference in New Issue
Block a user