-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding JavaScript wait examples (#1451)[deploy site]
* adding javascript test examples for waits * adding examples of Implicit wait and explicit wait for javascript * adding javascirpt wait examples in ja, pt, zh languages --------- Co-authored-by: Sri Harsha <[email protected]>
- Loading branch information
Showing
5 changed files
with
63 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const { suite } = require('selenium-webdriver/testing'); | ||
const { By, Browser, until } = require('selenium-webdriver'); | ||
const assert = require("node:assert"); | ||
|
||
suite(function (env) { | ||
describe('Element Interactions', function () { | ||
let driver; | ||
|
||
before(async function () { | ||
driver = await env.builder().build(); | ||
}); | ||
|
||
after(async () => await driver.quit()); | ||
|
||
it('fail', async function () { | ||
await driver.get('https://www.selenium.dev/selenium/web/dynamic.html'); | ||
await driver.findElement(By.id("adder")).click(); | ||
|
||
await assert.rejects(async () => { | ||
await driver.findElement(By.id("box0")) | ||
}, | ||
Error | ||
) | ||
}); | ||
|
||
it('sleep', async function () { | ||
await driver.get('https://www.selenium.dev/selenium/web/dynamic.html'); | ||
await driver.findElement(By.id("adder")).click(); | ||
|
||
await driver.sleep(2000); | ||
let added = await driver.findElement(By.id("box0")); | ||
|
||
assert.equal(await added.getAttribute('class'), "redbox") | ||
}); | ||
|
||
it('implicit', async function () { | ||
await driver.manage().setTimeouts({ implicit: 2000 }); | ||
await driver.get('https://www.selenium.dev/selenium/web/dynamic.html'); | ||
await driver.findElement(By.id("adder")).click(); | ||
|
||
let added = await driver.findElement(By.id("box0")); | ||
|
||
assert.equal(await added.getAttribute('class'), "redbox") | ||
}); | ||
|
||
it('explicit', async function () { | ||
await driver.get('https://www.selenium.dev/selenium/web/dynamic.html'); | ||
let revealed = await driver.findElement(By.id("revealed")); | ||
await driver.findElement(By.id("reveal")).click(); | ||
await driver.wait(until.elementIsVisible(revealed), 2000); | ||
await revealed.sendKeys("Displayed"); | ||
assert.equal(await revealed.getAttribute("value"), "Displayed") | ||
}) | ||
}); | ||
}, { browsers: [Browser.CHROME] }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters