Skip to content
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"private": true,
"scripts": {
"start": "cd packages/selenium-ide && pnpm run start",
"start:test-site": "http-server -p 8080 ./tests/static",
"build": "run-s build:ts build:ide",
"build:electron": "pnpm run --stream --filter @seleniumhq/selenium-ide build:electron",
"build:ide": "pnpm run --stream --filter @seleniumhq/selenium-ide build:webpack",
Expand Down
31 changes: 20 additions & 11 deletions packages/code-export-csharp-commons/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
// specific language governing permissions and limitations
// under the License.

import { codeExport as exporter, PrebuildEmitter } from 'side-code-export'
import { ExportFlexCommandShape, ProcessedCommandEmitter } from 'side-code-export/dist/code-export/emit'
import { ScriptShape } from 'side-code-export/src/code-export/preprocessor'
import {
codeExport as exporter,
PrebuildEmitter,
ExportFlexCommandShape,
ProcessedCommandEmitter,
EmitterContext,
ScriptShape,
} from 'side-code-export'
// eslint-disable-next-line node/no-unpublished-import
import { CommandShape } from '@seleniumhq/side-model'
import location from './location'
import selection from './selection'
Expand Down Expand Up @@ -130,10 +136,11 @@ function register(command: string, emitter: PrebuildEmitter) {
exporter.register.emitter({ command, emitter, emitters })
}

function emit(command: CommandShape) {
function emit(command: CommandShape, context: EmitterContext) {
return exporter.emit.command(command, emitters[command.command], {
variableLookup,
context,
emitNewWindowHandling,
variableLookup,
})
}

Expand Down Expand Up @@ -302,7 +309,10 @@ function emitControlFlowIf(script: any) {
})
}

function emitControlFlowForEach(collectionVarName: string, iteratorVarName: string) {
function emitControlFlowForEach(
collectionVarName: string,
iteratorVarName: string
) {
return Promise.resolve({
commands: [
{
Expand Down Expand Up @@ -500,12 +510,11 @@ async function emitMouseUp(locator: any) {
return Promise.resolve({ commands })
}

function emitOpen(target: string) {
function emitOpen(target: string, _value: string, context: EmitterContext) {
const url = /^(file|http|https):\/\//.test(target)
? `"${target}"`
: // @ts-expect-error globals yuck
`"${global.baseUrl}${target}"`
return Promise.resolve(`driver.Navigate().GoToUrl(${url});`)
? target
: `${context.project.url}${target}`
return Promise.resolve(`driver.Navigate().GoToUrl("${url}");`)
}

async function emitPause(time: any) {
Expand Down
13 changes: 9 additions & 4 deletions packages/code-export-csharp-xunit/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@
// under the License.

import { Command, location } from '@seleniumhq/code-export-csharp-commons'
import { codeExport as exporter } from 'side-code-export'
import { EmitterContext, codeExport as exporter } from 'side-code-export'
// eslint-disable-next-line node/no-unpublished-import
import { CommandShape } from '@seleniumhq/side-model'

const emitters = { ...Command.emitters }

exporter.register.preprocessors(emitters)

function emit(command: CommandShape) {
function emit(command: CommandShape, context: EmitterContext) {
return exporter.emit.command(command, emitters[command.command], {
variableLookup: Command.variableLookup,
context,
emitNewWindowHandling: Command.extras.emitNewWindowHandling,
variableLookup: Command.variableLookup,
})
}

Expand Down Expand Up @@ -154,7 +156,10 @@ async function emitVerifyNotEditable(locator: string) {
emitters.assertNotSelectedValue = emitVerifyNotSelectedValue
emitters.verifyNotSelectedValue = emitVerifyNotSelectedValue

async function emitVerifyNotSelectedValue(locator: string, expectedValue: string) {
async function emitVerifyNotSelectedValue(
locator: string,
expectedValue: string
) {
const commands = [
{ level: 0, statement: '{' },
{
Expand Down
10 changes: 6 additions & 4 deletions packages/code-export-java-junit/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
// specific language governing permissions and limitations
// under the License.

// eslint-disable-next-line node/no-unpublished-import
import { CommandShape } from '@seleniumhq/side-model'
import {
EmitterContext,
codeExport as exporter,
ExportFlexCommandShape,
PrebuildEmitter,
Expand Down Expand Up @@ -134,8 +136,9 @@ function register(command: string, emitter: PrebuildEmitter) {
exporter.register.emitter({ command, emitter, emitters })
}

function emit(command: CommandShape) {
function emit(command: CommandShape, context: EmitterContext) {
return exporter.emit.command(command, emitters[command.command], {
context,
variableLookup,
emitNewWindowHandling,
})
Expand Down Expand Up @@ -496,11 +499,10 @@ async function emitMouseUp(locator: string) {
return Promise.resolve({ commands })
}

function emitOpen(target: string) {
function emitOpen(target: string, _value: null, context: EmitterContext) {
const url = /^(file|http|https):\/\//.test(target)
? `"${target}"`
: // @ts-expect-error globals yuck
`"${global.baseUrl}${target}"`
: `"${context.project.url}${target}"`
return Promise.resolve(`driver.get(${url});`)
}

Expand Down
36 changes: 25 additions & 11 deletions packages/code-export-javascript-mocha/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
// under the License.

import {
EmitterContext,
codeExport as exporter,
ExportFlexCommandShape,
PrebuildEmitter,
ProcessedCommandEmitter,
ScriptShape,
} from 'side-code-export'
// eslint-disable-next-line node/no-unpublished-import
import { CommandShape } from '@seleniumhq/side-model'
import location from './location'
import selection from './selection'
Expand Down Expand Up @@ -134,8 +136,9 @@ function register(command: string, emitter: PrebuildEmitter) {
exporter.register.emitter({ command, emitter, emitters })
}

function emit(command: CommandShape) {
function emit(command: CommandShape, context: EmitterContext) {
return exporter.emit.command(command, emitters[command.command], {
context,
variableLookup,
emitNewWindowHandling,
})
Expand Down Expand Up @@ -182,7 +185,10 @@ function emitWaitForWindow() {
})
}

async function emitNewWindowHandling(command: CommandShape, emittedCommand: ExportFlexCommandShape) {
async function emitNewWindowHandling(
command: CommandShape,
emittedCommand: ExportFlexCommandShape
) {
return Promise.resolve(
`vars["windowHandles"] = await driver.getAllWindowHandles()\n${await emittedCommand}\nvars["${
command.windowHandleName
Expand Down Expand Up @@ -309,7 +315,10 @@ function emitControlFlowIf(script: ScriptShape) {
})
}

function emitControlFlowForEach(collectionVarName: string, iteratorVarName: string) {
function emitControlFlowForEach(
collectionVarName: string,
iteratorVarName: string
) {
return Promise.resolve({
commands: [
{
Expand Down Expand Up @@ -519,12 +528,11 @@ async function emitMouseUp(locator: string) {
return Promise.resolve({ commands })
}

function emitOpen(target: string) {
function emitOpen(target: string, _value: unknown, context: EmitterContext) {
const url = /^(file|http|https):\/\//.test(target)
? `"${target}"`
: // @ts-expect-error globals yuck
`"${global.baseUrl}${target}"`
return Promise.resolve(`await driver.get(${url})`)
? target
: `${context.project.url}${target}`
return Promise.resolve(`await driver.get("${url}")`)
}

async function emitPause(time: string) {
Expand Down Expand Up @@ -837,7 +845,10 @@ async function emitVerifyNotEditable(locator: string) {
return Promise.resolve({ commands })
}

async function emitVerifyNotSelectedValue(locator: string, expectedValue: string) {
async function emitVerifyNotSelectedValue(
locator: string,
expectedValue: string
) {
const commands = [
{ level: 0, statement: `{` },
{
Expand All @@ -848,7 +859,7 @@ async function emitVerifyNotSelectedValue(locator: string, expectedValue: string
},
{
level: 1,
statement: `assert.equal(value, "${exporter.emit.text(expectedValue)}")`
statement: `assert.equal(value, "${exporter.emit.text(expectedValue)}")`,
},
{ level: 0, statement: `}` },
]
Expand All @@ -864,7 +875,10 @@ async function emitVerifyNotText(locator: string, text: string) {
locator
)}).getText()`,
},
{ level: 1, statement: `assert.notEqual(text, "${exporter.emit.text(text)}")` },
{
level: 1,
statement: `assert.notEqual(text, "${exporter.emit.text(text)}")`,
},
{ level: 0, statement: `}` },
]
return Promise.resolve({ commands })
Expand Down
14 changes: 8 additions & 6 deletions packages/code-export-python-pytest/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
// under the License.

import {
EmitterContext,
codeExport as exporter,
ExportFlexCommandShape,
PrebuildEmitter,
ProcessedCommandEmitter,
ScriptShape,
} from 'side-code-export'
// eslint-disable-next-line node/no-unpublished-import
import { CommandShape } from '@seleniumhq/side-model'
import location from './location'
import selection from './selection'
Expand Down Expand Up @@ -134,8 +136,9 @@ function register(command: string, emitter: PrebuildEmitter) {
exporter.register.emitter({ command, emitter, emitters })
}

function emit(command: CommandShape) {
function emit(command: CommandShape, context: EmitterContext) {
return exporter.emit.command(command, emitters[command.command], {
context,
variableLookup,
emitNewWindowHandling,
})
Expand Down Expand Up @@ -499,12 +502,11 @@ async function emitMouseUp(locator: string) {
return Promise.resolve({ commands })
}

function emitOpen(target: string) {
function emitOpen(target: string, _value: string, context: EmitterContext) {
const url = /^(file|http|https):\/\//.test(target)
? `"${target}"`
: // @ts-expect-error globals yuck
`"${global.baseUrl}${target}"`
return Promise.resolve(`self.driver.get(${url})`)
? target
: `${context.project.url}${target}`
return Promise.resolve(`self.driver.get("${url}")`)
}

async function emitPause(time: number) {
Expand Down
15 changes: 10 additions & 5 deletions packages/code-export-ruby-rspec/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
// under the License.

import {
EmitterContext,
codeExport as exporter,
ExportFlexCommandShape,
ProcessedCommandEmitter,
ScriptShape,
} from 'side-code-export'
// eslint-disable-next-line node/no-unpublished-import
import { CommandShape } from '@seleniumhq/side-model'
import location from './location'
import selection from './selection'
Expand Down Expand Up @@ -133,8 +135,9 @@ function register(command: string, emitter: ProcessedCommandEmitter) {
exporter.register.emitter({ command, emitter, emitters })
}

function emit(command: CommandShape) {
function emit(command: CommandShape, context: EmitterContext) {
return exporter.emit.command(command, emitters[command.command], {
context,
variableLookup,
emitNewWindowHandling,
})
Expand Down Expand Up @@ -479,11 +482,10 @@ async function emitMouseUp(locator: string) {
return Promise.resolve({ commands })
}

function emitOpen(target: string) {
function emitOpen(target: string, _value: string, context: EmitterContext) {
const url = /^(file|http|https):\/\//.test(target)
? `'${target}'`
: // @ts-expect-error globals yuck
`"${global.baseUrl}${target}"`
: `"${context.project.url}${target}"`
return Promise.resolve(`@driver.get(${url})`)
}

Expand Down Expand Up @@ -767,7 +769,10 @@ async function emitVerifyNotEditable(locator: string) {
return Promise.resolve({ commands })
}

async function emitVerifyNotSelectedValue(locator: string, expectedValue: string) {
async function emitVerifyNotSelectedValue(
locator: string,
expectedValue: string
) {
const commands = [
{
level: 0,
Expand Down
2 changes: 0 additions & 2 deletions packages/side-code-export/src/code-export/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ export const languageFromOpts = (
beforeEachOptions,
enableDescriptionAsComment,
}) {
// @ts-expect-error globals yuck
global.baseUrl = baseUrl
const testDeclaration = opts.generateTestDeclaration(test.name)
const result = await emit.test(test, tests, {
...opts,
Expand Down
Loading