Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 05bc644

Browse files
harsha509diemol
authored andcommitted
Modify: Updated JS come sample to translated pages. (#345)
* Update: Updated sample code for translated pages Signed-off-by: Sri Harsha <sri_harsha509@hotmail.com> * Modify: Modified sample code for nl translated page which is different from remaining Signed-off-by: Sri Harsha <sri_harsha509@hotmail.com>
1 parent 04f716c commit 05bc644

File tree

2 files changed

+66
-7
lines changed

2 files changed

+66
-7
lines changed

‎docs_source_files/content/webdriver/js_alerts_prompts_and_confirmations.nl.md‎

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,22 @@ alert.Accept();
6969
# We don't have a Ruby code sample yet - Help us out and raise a PR
7070
{{< / code-panel >}}
7171
{{< code-panel language="javascript" >}}
72-
// We don't have a JavaScript code sample yet - Help us out and raise a PR
72+
//Click the link to activate the alert
73+
await driver.findElement(By.linkText('See an example alert')).click();
74+
75+
// Wait for the alert to be displayed
76+
await driver.wait(until.alertIsPresent());
77+
78+
// Store the alert in a variable
79+
let alert = await driver.switchTo().alert();
80+
81+
//Store the alert text in a variable
82+
let alertText = await alert.getText();
83+
84+
//Press the OK button
85+
await alert.accept();
86+
87+
// Note: To use await, the above code should be inside an async function
7388
{{< / code-panel >}}
7489
{{< / code-tab >}}
7590

@@ -134,7 +149,22 @@ alert.Dismiss();
134149
# We don't have a Ruby code sample yet - Help us out and raise a PR
135150
{{< / code-panel >}}
136151
{{< code-panel language="javascript" >}}
137-
// We don't have a JavaScript code sample yet - Help us out and raise a PR
152+
//Click the link to activate the alert
153+
await driver.findElement(By.linkText('See an example alert')).click();
154+
155+
// Wait for the alert to be displayed
156+
await driver.wait(until.alertIsPresent());
157+
158+
// Store the alert in a variable
159+
let alert = await driver.switchTo().alert();
160+
161+
//Store the alert text in a variable
162+
let alertText = await alert.getText();
163+
164+
//Press the Cancel button
165+
await alert.dismiss();
166+
167+
// Note: To use await, the above code should be inside an async function
138168
{{< / code-panel >}}
139169
{{< / code-tab >}}
140170

@@ -195,6 +225,21 @@ alert.Accept();
195225
# We don't have a Ruby code sample yet - Help us out and raise a PR
196226
{{< / code-panel >}}
197227
{{< code-panel language="javascript" >}}
198-
// We don't have a JavaScript code sample yet - Help us out and raise a PR
228+
//Click the link to activate the alert
229+
await driver.findElement(By.linkText('See an example alert')).click();
230+
231+
// Wait for the alert to be displayed
232+
await driver.wait(until.alertIsPresent());
233+
234+
// Store the alert in a variable
235+
let alert = await driver.switchTo().alert();
236+
237+
//Type your message
238+
await alert.sendKeys("Selenium");
239+
240+
//Press the OK button
241+
await alert.accept();
242+
243+
//Note: To use await, the above code should be inside an async function
199244
{{< / code-panel >}}
200245
{{< / code-tab >}}

‎docs_source_files/content/webdriver/web_element.nl.md‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,24 @@ search_box.send_keys("webdriver")
3535
# We don't have a Ruby code sample yet - Help us out and raise a PR
3636
{{< / code-panel >}}
3737
{{< code-panel language="javascript" >}}
38-
driver.get('http://www.google.com')
39-
.then(() => driver.findElement(By.tagName('form')) )
40-
.then((searchForm) => searchForm.findElement(By.name('q')) )
41-
.then((searchBox) => searchBox.sendKeys('webdriver') );
38+
let {Builder, By} = require('selenium-webdriver');
39+
driver = new Builder().forBrowser('chrome').build();
40+
41+
(async function test(){
42+
43+
//Navigate to url
44+
await driver.get('http://www.google.com');
45+
46+
//Get and store DOM element '<form>'
47+
let searchForm = await driver.findElement(By.name('f'));
48+
49+
//Get search box element from webElement 'form'
50+
let searchBar = await searchForm.findElement(By.name('q'));
51+
52+
//Perform action using WebElement
53+
await searchBar.sendKeys('Webdriver');
54+
55+
})();
4256
{{< / code-panel >}}
4357
{{< / code-tab >}}
4458

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /