Skip to content

Commit 3384cd2

Browse files
committed
docs(py): update webdriver feature listener docs
1 parent fd8ba8a commit 3384cd2

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

website_and_docs/content/documentation/webdriver/support_features/listeners.en.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,45 @@ aliases: [
77
]
88
---
99

10-
These allow you to execute custom actions in every time specific Selenium commands are sent
10+
These allow you to execute custom actions in every time specific Selenium commands are sent.
11+
12+
13+
## Define
14+
15+
A custom Listener needs to inherit from AbstractEventListener in Selenium and override the methods in AbstractEventListener.
16+
Here’s a simple example to print and log events:
17+
18+
{{< tabpane text=true >}}
19+
{{< tab header="Java" >}}
20+
{{< badge-code >}}
21+
{{< /tab >}}
22+
{{% tab header="Python" %}}
23+
{{< gh-codeblock path="examples/python/tests/support/test_listener.py" >}}
24+
{{% /tab %}}
25+
{{< tab header="CSharp" >}}
26+
{{< badge-code >}}
27+
{{< /tab >}}
28+
{{< tab header="Ruby" >}}
29+
{{< badge-code >}}
30+
{{< /tab >}}
31+
{{< tab header="JavaScript" >}}
32+
{{< badge-code >}}
33+
{{< /tab >}}
34+
{{< tab header="Kotlin" >}}
35+
{{< badge-code >}}
36+
{{< /tab >}}
37+
{{< /tabpane >}}
38+
39+
## Usage
40+
41+
Create an event listener driver through EventFiringWebDriver:
1142

1243
{{< tabpane text=true >}}
1344
{{< tab header="Java" >}}
1445
{{< badge-code >}}
1546
{{< /tab >}}
1647
{{% tab header="Python" %}}
17-
{{< gh-codeblock path="examples/python/tests/support/test_listener.py#L1-L25" >}}
48+
{{< gh-codeblock path="examples/python/tests/support/test_listener.py#L87-L96" >}}
1849
{{% /tab %}}
1950
{{< tab header="CSharp" >}}
2051
{{< badge-code >}}
@@ -29,3 +60,4 @@ These allow you to execute custom actions in every time specific Selenium comman
2960
{{< badge-code >}}
3061
{{< /tab >}}
3162
{{< /tabpane >}}
63+

website_and_docs/content/documentation/webdriver/support_features/listeners.zh-cn.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,42 @@ aliases: [
99

1010
允许您在每次发送特定 Selenium 命令时执行自定义操作
1111

12+
## 定义
13+
14+
自定义的Listener需要继承selenium中的AbstractEventListener同时重写AbstractEventListener中的方法,
15+
有一个简单打印和记录事件的例子:
16+
1217
{{< tabpane text=true >}}
1318
{{< tab header="Java" >}}
1419
{{< badge-code >}}
1520
{{< /tab >}}
1621
{{% tab header="Python" %}}
22+
{{< gh-codeblock path="examples/python/tests/support/test_listener.py#L1-L33" >}}
23+
{{% /tab %}}
24+
{{< tab header="CSharp" >}}
25+
{{< badge-code >}}
26+
{{< /tab >}}
27+
{{< tab header="Ruby" >}}
28+
{{< badge-code >}}
29+
{{< /tab >}}
30+
{{< tab header="JavaScript" >}}
1731
{{< badge-code >}}
32+
{{< /tab >}}
33+
{{< tab header="Kotlin" >}}
34+
{{< badge-code >}}
35+
{{< /tab >}}
36+
{{< /tabpane >}}
37+
38+
## 使用
39+
40+
通过EventFiringWebDriver创建监听事件driver:
41+
42+
{{< tabpane text=true >}}
43+
{{< tab header="Java" >}}
44+
{{< badge-code >}}
45+
{{< /tab >}}
46+
{{% tab header="Python" %}}
47+
{{< gh-codeblock path="examples/python/tests/support/test_listener.py#L87-L96" >}}
1848
{{% /tab %}}
1949
{{< tab header="CSharp" >}}
2050
{{< badge-code >}}

0 commit comments

Comments
 (0)