diff --git a/examples/javascript/test/getting_started/firstScript.spec.js b/examples/javascript/test/getting_started/firstScript.spec.js index 63cabf6a4fed..0aa870f331b6 100644 --- a/examples/javascript/test/getting_started/firstScript.spec.js +++ b/examples/javascript/test/getting_started/firstScript.spec.js @@ -1,4 +1,4 @@ -const {By, Builder, Browser} = require('selenium-webdriver'); +const {By, Builder} = require('selenium-webdriver'); const assert = require("assert"); (async function firstTest() { diff --git a/examples/javascript/test/getting_started/runningTests.spec.js b/examples/javascript/test/getting_started/runningTests.spec.js new file mode 100644 index 000000000000..31aa8732396e --- /dev/null +++ b/examples/javascript/test/getting_started/runningTests.spec.js @@ -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()); + }); \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.en.md b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.en.md index 9a84cada7415..0ba619a5bebe 100644 --- a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.en.md +++ b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.en.md @@ -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 >}} diff --git a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.ja.md b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.ja.md index 64dbbe32f5e8..f1d08996f5eb 100644 --- a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.ja.md +++ b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.ja.md @@ -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 >}} diff --git a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.pt-br.md b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.pt-br.md index 64dbbe32f5e8..f1d08996f5eb 100644 --- a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.pt-br.md @@ -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 >}} diff --git a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.zh-cn.md b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.zh-cn.md index 64dbbe32f5e8..f1d08996f5eb 100644 --- a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.zh-cn.md @@ -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 >}}