@seleniumhq/code-export-csharp-commons 3.16.0 → 3.17.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -263,7 +263,7 @@ exports[`command code emitter should emit \`open\` with absolute url 1`] = `"dri
263
263
  exports[`command code emitter should emit \`pause\` command 1`] = `
264
264
  "try {
265
265
  Thread.Sleep(300);
266
- } catch {
266
+ } catch (Exception e) {
267
267
  Console.WriteLine(\\"{0} Exception caught.\\", e);
268
268
  }"
269
269
  `;
@@ -464,6 +464,13 @@ exports[`command code emitter should emit \`waitForElementVisible\` command 1`]
464
464
  }"
465
465
  `;
466
466
 
467
+ exports[`command code emitter should emit \`waitForText\` command 1`] = `
468
+ "{
469
+ WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(30));
470
+ wait.Until(driver => driver.FindElement(By.CssSelector(\\"#blah\\")).Text == \\"text\\");
471
+ }"
472
+ `;
473
+
467
474
  exports[`command code emitter should emit \`while\` command 1`] = `
468
475
  Object {
469
476
  "body": "while ((Boolean) js.ExecuteScript(\\"return (true)\\")) {",
@@ -21,7 +21,7 @@ import {
21
21
  ControlFlowCommandNames,
22
22
  } from '../../../selenium-ide/src/neo/models/Command'
23
23
  import { opts } from '../../src/index'
24
- import { codeExport as exporter } from '@seleniumhq/side-utils'
24
+ import { codeExport as exporter } from '@seleniumhq/side-code-export'
25
25
 
26
26
  const commandPrefixPadding = opts.commandPrefixPadding
27
27
 
@@ -839,6 +839,14 @@ describe('command code emitter', () => {
839
839
  }
840
840
  return expect(prettify(command)).resolves.toMatchSnapshot()
841
841
  })
842
+ it('should emit `waitForText` command', () => {
843
+ const command = {
844
+ command: 'waitForText',
845
+ target: 'css=#blah',
846
+ value: 'text',
847
+ }
848
+ return expect(prettify(command)).resolves.toMatchSnapshot()
849
+ })
842
850
  it('should emit `answer on visible prompt` command', () => {
843
851
  const command = {
844
852
  command: 'webdriverAnswerOnVisiblePrompt',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seleniumhq/code-export-csharp-commons",
3
- "version": "3.16.0",
3
+ "version": "3.17.4",
4
4
  "description": "Commons for exporting Selenium IDE project contents to C#",
5
5
  "repository": "https://github.com/SeleniumHQ/selenium-ide",
6
6
  "keywords": [
@@ -20,5 +20,5 @@
20
20
  "@babel/plugin-proposal-object-rest-spread": "^7.4.4",
21
21
  "@babel/preset-env": "^7.4.5"
22
22
  },
23
- "gitHead": "70be270a6733b9cd14a9a86f11cbffaf7892c585"
23
+ "gitHead": "4c3ce70a9056dc81b1f24f2e7232af2c11cc80a9"
24
24
  }
package/src/command.js CHANGED
@@ -15,7 +15,7 @@
15
15
  // specific language governing permissions and limitations
16
16
  // under the License.
17
17
 
18
- import { codeExport as exporter } from '@seleniumhq/side-utils'
18
+ import { codeExport as exporter } from '@seleniumhq/side-code-export'
19
19
  import location from './location'
20
20
  import selection from './selection'
21
21
 
@@ -112,6 +112,7 @@ export const emitters = {
112
112
  waitForElementNotEditable: emitWaitForElementNotEditable,
113
113
  waitForElementNotPresent: emitWaitForElementNotPresent,
114
114
  waitForElementNotVisible: emitWaitForElementNotVisible,
115
+ waitForText: emitWaitForText,
115
116
  webDriverAnswerOnVisiblePrompt: emitAnswerOnNextPrompt,
116
117
  webDriverChooseCancelOnVisibleConfirmation: emitChooseCancelOnNextConfirmation,
117
118
  webDriverChooseCancelOnVisiblePrompt: emitChooseCancelOnNextConfirmation,
@@ -507,7 +508,7 @@ async function emitPause(time) {
507
508
  const commands = [
508
509
  { level: 0, statement: 'try {' },
509
510
  { level: 1, statement: `Thread.Sleep(${time});` },
510
- { level: 0, statement: '} catch {' },
511
+ { level: 0, statement: '} catch (Exception e) {' },
511
512
  { level: 1, statement: 'Console.WriteLine("{0} Exception caught.", e);' },
512
513
  { level: 0, statement: '}' },
513
514
  ]
@@ -940,6 +941,27 @@ async function emitWaitForElementEditable(locator, timeout) {
940
941
  return Promise.resolve({ commands })
941
942
  }
942
943
 
944
+ async function emitWaitForText(locator, text) {
945
+ const timeout = 30000
946
+ const commands = [
947
+ { level: 0, statement: '{' },
948
+ {
949
+ level: 1,
950
+ statement: `WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(${Math.floor(
951
+ timeout / 1000
952
+ )}));`,
953
+ },
954
+ {
955
+ level: 1,
956
+ statement: `wait.Until(driver => driver.FindElement(${await location.emit(
957
+ locator
958
+ )}).Text == "${text}");`,
959
+ },
960
+ { level: 0, statement: '}' },
961
+ ]
962
+ return Promise.resolve({ commands })
963
+ }
964
+
943
965
  function skip() {
944
966
  return Promise.resolve('')
945
967
  }
package/src/location.js CHANGED
@@ -15,7 +15,7 @@
15
15
  // specific language governing permissions and limitations
16
16
  // under the License.
17
17
 
18
- import { codeExport as exporter } from '@seleniumhq/side-utils'
18
+ import { codeExport as exporter } from '@seleniumhq/side-code-export'
19
19
 
20
20
  const emitters = {
21
21
  id: emitId,
package/src/selection.js CHANGED
@@ -15,7 +15,7 @@
15
15
  // specific language governing permissions and limitations
16
16
  // under the License.
17
17
 
18
- import { codeExport as exporter } from '@seleniumhq/side-utils'
18
+ import { codeExport as exporter } from '@seleniumhq/side-code-export'
19
19
 
20
20
  const emitters = {
21
21
  id: emitId,