Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Run playback on standalone selenium servers #230

Merged
merged 21 commits into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ dist/
.web-extension-id
*.log
tests/webdriver/
tests/static/webdriver.js
.*.swp
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ before_install:
- docker-compose up -d
install:
- yarn --ignore-engines
- yarn build:webdriver
- yarn build:selianize
- yarn build:runner
script:
- yarn lint
- yarn test
- yarn test:webdriver --server http://localhost:4444/wd/hub
- yarn test:webdriver
- yarn test:runner --server http://localhost:4444/wd/hub
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
"build:ext": "cd packages/selenium-ide && yarn build",
"build:runner": "cd packages/selenium-side-runner && yarn build",
"build:selianize": "cd packages/selianize && yarn build",
"build:webdriver": "cd packages/webdriver && yarn build",
"build:webdriver:dev": "cd packages/webdriver && yarn build:dev",
"build:ext:prod": "cd packages/selenium-ide && yarn build-prod",
"pack:chrome": "cd packages/selenium-ide && yarn build-chrome",
"pack:firefox": "cd packages/selenium-ide && yarn build-firefox",
"pack:runner": "cd packages/selenium-side-runner && yarn pkg",
"test": "jest",
"test:webdriver": "cd tests/examples && node ../../packages/selenium-side-runner/dist/index.js *.side",
"test:runner": "cd tests/examples && node ../../packages/selenium-side-runner/dist/index.js *.side",
"test:webdriver": "jest --testMatch \"**/packages/webdriver/test/**/*.spec.js\"",
"lint": "yarn lint:scripts && yarn lint:styles",
"lint:scripts": "eslint packages/selenium-ide/src/neo/ packages/selenium-ide/src/plugin/ packages/selenium-ide/src/router/ packages/selenium-ide/src/api/ packages/selenium-side-runner/src/ packages/selianize/__tests__/ packages/selianize/src/ --ext .js --ext .jsx",
"lint:scripts": "eslint packages/selenium-ide/src/neo/ packages/selenium-ide/src/plugin/ packages/selenium-ide/src/router/ packages/selenium-ide/src/api/ packages/selenium-side-runner/src/ packages/selianize/__tests__/ packages/selianize/src/ packages/webdriver/src/ --ext .js --ext .jsx",
"lint:styles": "stylelint \"packages/selenium-ide/src/neo/**/*.css\"",
"postinstall": "lerna bootstrap"
},
Expand Down
8 changes: 2 additions & 6 deletions packages/selenium-ide/src/neo/IO/SideeX/ext-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { recorder } from "./editor";
import Debugger from "../debugger";
import PlaybackState from "../../stores/view/PlaybackState";
import variables from "../../stores/view/Variables";
import { absolutifyUrl } from "../playback/utils";

const parsedUA = parser(window.navigator.userAgent);

Expand Down Expand Up @@ -201,12 +202,7 @@ export default class ExtCommand {
}

doOpen(targetUrl) {
let url = targetUrl;
try {
url = (new URL(targetUrl)).href;
} catch (e) {
url = (new URL(targetUrl, this.baseUrl)).href;
}
const url = absolutifyUrl(targetUrl, this.baseUrl);
return browser.tabs.update(this.currentPlayingTabId, {
url: url
});
Expand Down
19 changes: 13 additions & 6 deletions packages/selenium-ide/src/neo/IO/SideeX/playback.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ extCommand.doSetSpeed = (speed) => {
let baseUrl = "";
let ignoreBreakpoint = false;
let breakOnNextCommand = false;
let executor = undefined;

export function play(currUrl) {
export function play(currUrl, exec) {
baseUrl = currUrl;
ignoreBreakpoint = false;
executor = exec;
initPlaybackTree();
return prepareToPlay()
.then(executionLoop)
Expand Down Expand Up @@ -132,9 +134,9 @@ function runNextCommand() {
// paused
if (isStopping()) return false;
}
if (extCommand.isExtCommand(command.command)) {
if (executor.isExtCommand(command.command)) {
return doDelay().then(() => {
return (PlaybackState.currentExecutingCommandNode.execute(extCommand))
return (PlaybackState.currentExecutingCommandNode.execute(executor))
.then((result) => {
// we need to set the stackIndex manually because run command messes with that
PlaybackState.setCommandStateAtomically(command.id, stackIndex, PlaybackStates.Passed);
Expand All @@ -157,15 +159,20 @@ function runNextCommand() {
}

function prepareToPlay() {
return extCommand.init(baseUrl);
return executor.init(baseUrl);
}

function prepareToPlayAfterConnectionFailed() {
return Promise.resolve(true);
}

function finishPlaying() {
if (!PlaybackState.paused) PlaybackState.finishPlaying();
async function finishPlaying() {
if (!PlaybackState.paused) {
if (executor.cleanup) {
await executor.cleanup();
}
PlaybackState.finishPlaying();
}
}

function catchPlayingError(message) {
Expand Down
27 changes: 27 additions & 0 deletions packages/selenium-ide/src/neo/IO/playback/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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.

export function absolutifyUrl(targetUrl, baseUrl) {
let url = targetUrl;
try {
url = (new URL(targetUrl)).href;
} catch (e) {
url = (new URL(targetUrl, baseUrl)).href;
}

return url;
}
Loading