Skip to content

Commit

Permalink
Add js test to run with mocha [deploy site]
Browse files Browse the repository at this point in the history
  • Loading branch information
harsha509 committed Oct 10, 2023
1 parent e37ea0f commit 091f5a0
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {By, Builder, Browser} = require('selenium-webdriver');
const {By, Builder} = require('selenium-webdriver');
const assert = require("assert");

(async function firstTest() {
Expand Down
31 changes: 31 additions & 0 deletions examples/javascript/test/getting_started/runningTests.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const {By, Builder} = require('selenium-webdriver');
const assert = require("assert");

describe('First script', function () {
let driver;

before(async function () {
driver = await new Builder().forBrowser('chrome').build();
});

it('First Selenium script with mocha', async function () {
await driver.get('https://www.selenium.dev/selenium/web/web-form.html');

let title = await driver.getTitle();
assert.equal("Web form", title);

await driver.manage().setTimeouts({implicit: 500});

let textBox = await driver.findElement(By.name('my-text'));
let submitButton = await driver.findElement(By.css('button'));

await textBox.sendKeys('Selenium');
await submitButton.click();

let message = await driver.findElement(By.id('message'));
let value = await message.getText();
assert.equal("Received!", value);
});

after(async () => await driver.quit());
});
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Here's an example of that code using a test runner:
{{< gh-codeblock path="examples/ruby/spec/getting_started/using_selenium_spec.rb" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/javascript/test/getting_started/runningTests.spec.js" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Here's an example of that code using a test runner:
{{< gh-codeblock path="examples/ruby/spec/getting_started/using_selenium_spec.rb" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/javascript/test/getting_started/runningTests.spec.js" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Here's an example of that code using a test runner:
{{< gh-codeblock path="examples/ruby/spec/getting_started/using_selenium_spec.rb" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/javascript/test/getting_started/runningTests.spec.js" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Here's an example of that code using a test runner:
{{< gh-codeblock path="examples/ruby/spec/getting_started/using_selenium_spec.rb" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/javascript/test/getting_started/runningTests.spec.js" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
Expand Down

0 comments on commit 091f5a0

Please sign in to comment.