Skip to content

Commit d018624

Browse files
author
David Haeffner
committed
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide
2 parents d85d975 + 85e333c commit d018624

File tree

6 files changed

+51
-16
lines changed

6 files changed

+51
-16
lines changed

packages/selenium-ide/src/content/selenium-api.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,24 @@ Selenium.prototype.doStoreEval = function() {
548548

549549
Selenium.prototype.doStoreText = function(locator, varName) {
550550
throwIfNoVarNameProvided(varName)
551-
const element = this.findElementVisible(locator)
551+
let text
552+
try {
553+
// Try to get the text if the element is visible
554+
const element = this.findElementVisible(locator)
555+
text = bot.dom.getVisibleText(element)
556+
} catch (e) {
557+
// element is not visible, but it may be due to the fact that it has no text
558+
const element = this.browserbot.findElement(locator)
559+
if (element.innerHTML === '') {
560+
// element is empty then return empty string
561+
text = ''
562+
} else {
563+
// element has content this is indeed invisible
564+
throw e
565+
}
566+
}
552567
return browser.runtime.sendMessage({
553-
storeStr: bot.dom.getVisibleText(element),
568+
storeStr: text,
554569
storeVar: varName,
555570
})
556571
}
@@ -594,10 +609,6 @@ Selenium.prototype.doStoreAttribute = function(locator, varName) {
594609
})
595610
}
596611

597-
Selenium.prototype.doEcho = function(value) {
598-
return browser.runtime.sendMessage({ echoStr: value })
599-
}
600-
601612
function waitUntil(condition, target, timeout, failureMessage) {
602613
if (!timeout) {
603614
throw new Error('Timeout not specified.')

packages/selenium-ide/src/neo/IO/SideeX/ext-command.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import browser from 'webextension-polyfill'
1919
import Debugger, { convertLocator } from '../debugger'
2020
import PlaybackState from '../../stores/view/PlaybackState'
2121
import variables from '../../stores/view/Variables'
22+
import { Logger, Channels } from '../../stores/view/Logs'
2223
import FrameNotFoundError from '../../../errors/frame-not-found'
2324
import { absolutifyUrl } from '../playback/utils'
2425
import { userAgent as parsedUA } from '../../../common/utils'
@@ -40,6 +41,7 @@ export default class ExtCommand {
4041
// TODO: flexible wait
4142
this.waitInterval = 500
4243
this.waitTimes = 60
44+
this.logger = new Logger(Channels.PLAYBACK)
4345

4446
this.attached = false
4547

@@ -377,6 +379,10 @@ export default class ExtCommand {
377379
await PlaybackState.break()
378380
}
379381

382+
async doEcho(string) {
383+
this.logger.log(`echo: ${string}`)
384+
}
385+
380386
doOpen(targetUrl) {
381387
const url = absolutifyUrl(targetUrl, this.baseUrl)
382388
return browser.tabs
@@ -835,6 +841,7 @@ export default class ExtCommand {
835841
isExtCommand(command) {
836842
switch (command) {
837843
case 'debugger':
844+
case 'echo':
838845
case 'pause':
839846
case 'open':
840847
case 'selectFrame':

packages/selenium-ide/src/neo/IO/SideeX/formatCommand.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function xlateArgument(value) {
3131
const regexp = /\$\{(.*?)\}/g
3232
let lastIndex = 0
3333
while ((r2 = regexp.exec(value))) {
34-
if (variables.get(r2[1])) {
34+
if (variables.has(r2[1])) {
3535
if (r2.index - lastIndex > 0) {
3636
parts.push(string(value.substring(lastIndex, r2.index)))
3737
}
@@ -50,7 +50,7 @@ export function xlateArgument(value) {
5050
if (lastIndex < value.length) {
5151
parts.push(string(value.substring(lastIndex, value.length)))
5252
}
53-
return parts.join('')
53+
return parts.map(String).join('')
5454
} else {
5555
return string(value)
5656
}
@@ -113,9 +113,6 @@ function handleFormatCommand(message, _sender, sendResponse) {
113113
} else if (message.storeVar) {
114114
variables.set(message.storeVar, message.storeStr)
115115
return sendResponse(true)
116-
} else if (message.echoStr) {
117-
logger.log('echo: ' + message.echoStr)
118-
return sendResponse(true)
119116
} else if (
120117
message.log &&
121118
output.logs[output.logs.length - 1].message.indexOf(message.log.message) ===

packages/selenium-ide/src/neo/IO/playback/webdriver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ export default class WebDriverExecutor {
409409
// other commands
410410

411411
async doEcho(string) {
412-
this.logger.log(string)
412+
this.logger.log(`echo: ${string}`)
413413
return Promise.resolve()
414414
}
415415

packages/selenium-ide/src/neo/__test__/IO/playback/formatCommand.spec.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,32 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
import { interpolateScript } from '../../../IO/SideeX/formatCommand'
18+
import {
19+
interpolateScript,
20+
xlateArgument,
21+
} from '../../../IO/SideeX/formatCommand'
1922
import variables from '../../../stores/view/Variables'
2023

21-
describe('interpolate script', () => {
22-
afterEach(() => {
23-
variables.clear()
24+
afterEach(() => {
25+
variables.clear()
26+
})
27+
28+
describe('interpolate string', () => {
29+
it('should interpolate false values', () => {
30+
variables.set('a', undefined)
31+
expect(xlateArgument('${a}')).toBe('undefined')
32+
variables.set('a', null)
33+
expect(xlateArgument('${a}')).toBe('null')
34+
variables.set('a', false)
35+
expect(xlateArgument('${a}')).toBe('false')
36+
variables.set('a', 0)
37+
expect(xlateArgument('${a}')).toBe('0')
38+
variables.set('a', '')
39+
expect(xlateArgument('${a}')).toBe('')
2440
})
41+
})
42+
43+
describe('interpolate script', () => {
2544
it('should not interpolate a script without variables', () => {
2645
const script = 'return 1'
2746
expect(interpolateScript(script).script).toEqual(script)

packages/selenium-side-runner/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ function runProject(project) {
303303
function runJest(project) {
304304
return new Promise((resolve, reject) => {
305305
const args = [
306+
'--no-watchman',
306307
'--testMatch',
307308
`{**/*${program.filter}*/*.test.js,**/*${program.filter}*.test.js}`,
308309
]

0 commit comments

Comments
 (0)