Skip to content

Commit cb981c7

Browse files
Arpan3323chamiz
authored andcommitted
Updated WebDriver alert interaction Python examples to reference code from Python tests (#1698)
* updated alerts.md to include links to python tests * restore .toml --------- Co-authored-by: Diego Molina <[email protected]> [deploy]
1 parent f7af473 commit cb981c7

File tree

4 files changed

+42
-175
lines changed

4 files changed

+42
-175
lines changed

Diff for: website_and_docs/content/documentation/webdriver/interactions/alerts.en.md

+15-45
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,11 @@ String text = alert.getText();
3939
//Press the OK button
4040
alert.accept();
4141
{{< /tab >}}
42-
{{< tab header="Python" >}}
43-
# Click the link to activate the alert
44-
driver.find_element(By.LINK_TEXT, "See an example alert").click()
45-
46-
# Wait for the alert to be displayed and store it in a variable
47-
alert = wait.until(expected_conditions.alert_is_present())
4842

49-
# Store the alert text in a variable
50-
text = alert.text
43+
{{< tab header="Python" text=true >}}
44+
{{< gh-codeblock path="examples/python/tests/interactions/test_alerts.py#L12-L18" >}}
45+
{{< /tab >}}
5146

52-
# Press the OK button
53-
alert.accept()
54-
{{< /tab >}}
5547
{{< tab header="CSharp" >}}
5648
//Click the link to activate the alert
5749
driver.FindElement(By.LinkText("See an example alert")).Click();
@@ -78,9 +70,9 @@ alert_text = alert.text
7870
# Press on OK button
7971
alert.accept
8072
{{< /tab >}}
81-
{{< tab header="JavaScript" text=true >}}
82-
{{< gh-codeblock path="examples/javascript/test/interactions/alert.spec.js#L19-L21" >}}
83-
{{< /tab >}}
73+
{{< tab header="JavaScript" text=true >}}
74+
{{< gh-codeblock path="examples/javascript/test/interactions/alert.spec.js#L19-L21" >}}
75+
{{< /tab >}}
8476
{{< tab header="Kotlin" >}}
8577
//Click the link to activate the alert
8678
driver.findElement(By.linkText("See an example alert")).click()
@@ -122,22 +114,11 @@ String text = alert.getText();
122114
//Press the Cancel button
123115
alert.dismiss();
124116
{{< /tab >}}
125-
{{< tab header="Python" >}}
126-
# Click the link to activate the alert
127-
driver.find_element(By.LINK_TEXT, "See a sample confirm").click()
128-
129-
# Wait for the alert to be displayed
130-
wait.until(expected_conditions.alert_is_present())
131-
132-
# Store the alert in a variable for reuse
133-
alert = driver.switch_to.alert
134117

135-
# Store the alert text in a variable
136-
text = alert.text
118+
{{< tab header="Python" text=true >}}
119+
{{< gh-codeblock path="examples/python/tests/interactions/test_alerts.py#L26-L32" >}}
120+
{{< /tab >}}
137121

138-
# Press the Cancel button
139-
alert.dismiss()
140-
{{< /tab >}}
141122
{{< tab header="CSharp" >}}
142123
//Click the link to activate the alert
143124
driver.FindElement(By.LinkText("See a sample confirm")).Click();
@@ -167,9 +148,9 @@ alert_text = alert.text
167148
# Press on Cancel button
168149
alert.dismiss
169150
{{< /tab >}}
170-
{{< tab header="JavaScript" text=true >}}
171-
{{< gh-codeblock path="examples/javascript/test/interactions/alert.spec.js#L30-L32" >}}
172-
{{< /tab >}}
151+
{{< tab header="JavaScript" text=true >}}
152+
{{< gh-codeblock path="examples/javascript/test/interactions/alert.spec.js#L30-L32" >}}
153+
{{< /tab >}}
173154
{{< tab header="Kotlin" >}}
174155
//Click the link to activate the alert
175156
driver.findElement(By.linkText("See a sample confirm")).click()
@@ -213,22 +194,11 @@ alert.sendKeys("Selenium");
213194
//Press the OK button
214195
alert.accept();
215196
{{< /tab >}}
216-
{{< tab header="Python" >}}
217-
# Click the link to activate the alert
218-
driver.find_element(By.LINK_TEXT, "See a sample prompt").click()
219-
220-
# Wait for the alert to be displayed
221-
wait.until(expected_conditions.alert_is_present())
222-
223-
# Store the alert in a variable for reuse
224-
alert = Alert(driver)
225197

226-
# Type your message
227-
alert.send_keys("Selenium")
198+
{{< tab header="Python" text=true >}}
199+
{{< gh-codeblock path="examples/python/tests/interactions/test_alerts.py#L40-L47" >}}
200+
{{< /tab >}}
228201

229-
# Press the OK button
230-
alert.accept()
231-
{{< /tab >}}
232202
{{< tab header="CSharp" >}}
233203
//Click the link to activate the alert
234204
driver.FindElement(By.LinkText("See a sample prompt")).Click();

Diff for: website_and_docs/content/documentation/webdriver/interactions/alerts.ja.md

+9-39
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,11 @@ String text = alert.getText();
3434
//Press the OK button
3535
alert.accept();
3636
{{< /tab >}}
37-
{{< tab header="Python" >}}
38-
# Click the link to activate the alert
39-
driver.find_element(By.LINK_TEXT, "See an example alert").click()
40-
41-
# Wait for the alert to be displayed and store it in a variable
42-
alert = wait.until(expected_conditions.alert_is_present())
4337

44-
# Store the alert text in a variable
45-
text = alert.text
38+
{{< tab header="Python" text=true >}}
39+
{{< gh-codeblock path="examples/python/tests/interactions/test_alerts.py#L12-L18" >}}
40+
{{< /tab >}}
4641

47-
# Press the OK button
48-
alert.accept()
49-
{{< /tab >}}
5042
{{< tab header="CSharp" >}}
5143
//Click the link to activate the alert
5244
driver.FindElement(By.LinkText("See an example alert")).Click();
@@ -115,22 +107,11 @@ String text = alert.getText();
115107
//Press the Cancel button
116108
alert.dismiss();
117109
{{< /tab >}}
118-
{{< tab header="Python" >}}
119-
# Click the link to activate the alert
120-
driver.find_element(By.LINK_TEXT, "See a sample confirm").click()
121-
122-
# Wait for the alert to be displayed
123-
wait.until(expected_conditions.alert_is_present())
124-
125-
# Store the alert in a variable for reuse
126-
alert = driver.switch_to.alert
127110

128-
# Store the alert text in a variable
129-
text = alert.text
111+
{{< tab header="Python" text=true >}}
112+
{{< gh-codeblock path="examples/python/tests/interactions/test_alerts.py#L26-L32" >}}
113+
{{< /tab >}}
130114

131-
# Press the Cancel button
132-
alert.dismiss()
133-
{{< /tab >}}
134115
{{< tab header="CSharp" >}}
135116
//Click the link to activate the alert
136117
driver.FindElement(By.LinkText("See a sample confirm")).Click();
@@ -203,22 +184,11 @@ alert.sendKeys("Selenium");
203184
//Press the OK button
204185
alert.accept();
205186
{{< /tab >}}
206-
{{< tab header="Python" >}}
207-
# Click the link to activate the alert
208-
driver.find_element(By.LINK_TEXT, "See a sample prompt").click()
209187

210-
# Wait for the alert to be displayed
211-
wait.until(expected_conditions.alert_is_present())
212-
213-
# Store the alert in a variable for reuse
214-
alert = Alert(driver)
215-
216-
# Type your message
217-
alert.send_keys("Selenium")
188+
{{< tab header="Python" text=true >}}
189+
{{< gh-codeblock path="examples/python/tests/interactions/test_alerts.py#L40-L47" >}}
190+
{{< /tab >}}
218191

219-
# Press the OK button
220-
alert.accept()
221-
{{< /tab >}}
222192
{{< tab header="CSharp" >}}
223193
//Click the link to activate the alert
224194
driver.FindElement(By.LinkText("See a sample prompt")).Click();

Diff for: website_and_docs/content/documentation/webdriver/interactions/alerts.pt-br.md

+9-52
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,11 @@ String text = alert.getText();
3838
//Press the OK button
3939
alert.accept();
4040
{{< /tab >}}
41-
{{< tab header="Python" >}}
42-
# Click the link to activate the alert
43-
driver.find_element(By.LINK_TEXT, "See an example alert").click()
44-
45-
# Wait for the alert to be displayed and store it in a variable
46-
alert = wait.until(expected_conditions.alert_is_present())
47-
48-
# Store the alert text in a variable
49-
text = alert.text
50-
51-
# Press the OK button
52-
alert.accept()
53-
{{< /tab >}}
54-
{{< tab header="CSharp" >}}
55-
//Click the link to activate the alert
56-
driver.FindElement(By.LinkText("See an example alert")).Click();
57-
58-
//Wait for the alert to be displayed and store it in a variable
59-
IAlert alert = wait.Until(ExpectedConditions.AlertIsPresent());
6041

61-
//Store the alert text in a variable
62-
string text = alert.Text;
42+
{{< tab header="Python" text=true >}}
43+
{{< gh-codeblock path="examples/python/tests/interactions/test_alerts.py#L12-L18" >}}
44+
{{< /tab >}}
6345

64-
//Press the OK button
65-
alert.Accept();
66-
{{< /tab >}}
6746
{{< tab header="Ruby" >}}
6847
# Click the link to activate the alert
6948
driver.find_element(:link_text, 'See an example alert').click
@@ -120,22 +99,11 @@ String text = alert.getText();
12099
//Press the Cancel button
121100
alert.dismiss();
122101
{{< /tab >}}
123-
{{< tab header="Python" >}}
124-
# Click the link to activate the alert
125-
driver.find_element(By.LINK_TEXT, "See a sample confirm").click()
126-
127-
# Wait for the alert to be displayed
128-
wait.until(expected_conditions.alert_is_present())
129102

130-
# Store the alert in a variable for reuse
131-
alert = driver.switch_to.alert
132-
133-
# Store the alert text in a variable
134-
text = alert.text
103+
{{< tab header="Python" text=true >}}
104+
{{< gh-codeblock path="examples/python/tests/interactions/test_alerts.py#L26-L32" >}}
105+
{{< /tab >}}
135106

136-
# Press the Cancel button
137-
alert.dismiss()
138-
{{< /tab >}}
139107
{{< tab header="CSharp" >}}
140108
//Click the link to activate the alert
141109
driver.FindElement(By.LinkText("See a sample confirm")).Click();
@@ -210,22 +178,11 @@ alert.sendKeys("Selenium");
210178
//Press the OK button
211179
alert.accept();
212180
{{< /tab >}}
213-
{{< tab header="Python" >}}
214-
# Click the link to activate the alert
215-
driver.find_element(By.LINK_TEXT, "See a sample prompt").click()
216-
217-
# Wait for the alert to be displayed
218-
wait.until(expected_conditions.alert_is_present())
219181

220-
# Store the alert in a variable for reuse
221-
alert = Alert(driver)
222-
223-
# Type your message
224-
alert.send_keys("Selenium")
182+
{{< tab header="Python" text=true >}}
183+
{{< gh-codeblock path="examples/python/tests/interactions/test_alerts.py#L40-L47" >}}
184+
{{< /tab >}}
225185

226-
# Press the OK button
227-
alert.accept()
228-
{{< /tab >}}
229186
{{< tab header="CSharp" >}}
230187
//Click the link to activate the alert
231188
driver.FindElement(By.LinkText("See a sample prompt")).Click();

Diff for: website_and_docs/content/documentation/webdriver/interactions/alerts.zh-cn.md

+9-39
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,11 @@ String text = alert.getText();
3131
//Press the OK button
3232
alert.accept();
3333
{{< /tab >}}
34-
{{< tab header="Python" >}}
35-
# Click the link to activate the alert
36-
driver.find_element(By.LINK_TEXT, "See an example alert").click()
37-
38-
# Wait for the alert to be displayed and store it in a variable
39-
alert = wait.until(expected_conditions.alert_is_present())
4034

41-
# Store the alert text in a variable
42-
text = alert.text
35+
{{< tab header="Python" text=true >}}
36+
{{< gh-codeblock path="examples/python/tests/interactions/test_alerts.py#L12-L18" >}}
37+
{{< /tab >}}
4338

44-
# Press the OK button
45-
alert.accept()
46-
{{< /tab >}}
4739
{{< tab header="CSharp" >}}
4840
//Click the link to activate the alert
4941
driver.FindElement(By.LinkText("See an example alert")).Click();
@@ -111,22 +103,11 @@ String text = alert.getText();
111103
//Press the Cancel button
112104
alert.dismiss();
113105
{{< /tab >}}
114-
{{< tab header="Python" >}}
115-
# Click the link to activate the alert
116-
driver.find_element(By.LINK_TEXT, "See a sample confirm").click()
117-
118-
# Wait for the alert to be displayed
119-
wait.until(expected_conditions.alert_is_present())
120-
121-
# Store the alert in a variable for reuse
122-
alert = driver.switch_to.alert
123106

124-
# Store the alert text in a variable
125-
text = alert.text
107+
{{< tab header="Python" text=true >}}
108+
{{< gh-codeblock path="examples/python/tests/interactions/test_alerts.py#L26-L32" >}}
109+
{{< /tab >}}
126110

127-
# Press the Cancel button
128-
alert.dismiss()
129-
{{< /tab >}}
130111
{{< tab header="CSharp" >}}
131112
//Click the link to activate the alert
132113
driver.FindElement(By.LinkText("See a sample confirm")).Click();
@@ -198,22 +179,11 @@ alert.sendKeys("Selenium");
198179
//Press the OK button
199180
alert.accept();
200181
{{< /tab >}}
201-
{{< tab header="Python" >}}
202-
# Click the link to activate the alert
203-
driver.find_element(By.LINK_TEXT, "See a sample prompt").click()
204182

205-
# Wait for the alert to be displayed
206-
wait.until(expected_conditions.alert_is_present())
207-
208-
# Store the alert in a variable for reuse
209-
alert = Alert(driver)
210-
211-
# Type your message
212-
alert.send_keys("Selenium")
183+
{{< tab header="Python" text=true >}}
184+
{{< gh-codeblock path="examples/python/tests/interactions/test_alerts.py#L40-L47" >}}
185+
{{< /tab >}}
213186

214-
# Press the OK button
215-
alert.accept()
216-
{{< /tab >}}
217187
{{< tab header="CSharp" >}}
218188
//Click the link to activate the alert
219189
driver.FindElement(By.LinkText("See a sample prompt")).Click();

0 commit comments

Comments
 (0)