Skip to content

Commit 766d133

Browse files
committed
Update Information docs with new getDomAttribute() and getDomProperty() methods
1 parent 852503c commit 766d133

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

examples/dotnet/SeleniumDocs/Elements/InformationTest.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ public void TestInformationCommands(){
6060
IWebElement emailTxt = driver.FindElement(By.Name("email_input"));
6161
// fetch the value property associated with the textbox
6262
string valueInfo = emailTxt.GetAttribute("value");
63+
64+
// New in Selenium 4.27+
65+
// fetches the DOM attribute exactly as written in the HTML source
66+
string domAttribute = emailTxt.GetDomAttribute("name");
67+
68+
// fetches the live property value from the DOM object (may differ at runtime)
69+
string domProperty = emailTxt.GetDomProperty("name");
70+
6371
Assert.AreEqual(valueInfo, "admin@localhost");
6472

6573
//Quit the driver

examples/python/tests/elements/test_information.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,12 @@ def test_informarion():
4444
# FetchAttributes
4545
email_txt = driver.find_element(By.NAME, "email_input")
4646
value_info = email_txt.get_attribute("value")
47+
48+
# New in Selenium 4.27+
49+
# fetches the DOM attribute exactly as written in the HTML source
50+
dom_attribute = email_txt.get_dom_attribute("name")
51+
52+
# fetches the live property value from the DOM object (may differ at runtime)
53+
dom_property = email_txt.get_dom_property("name")
54+
4755
assert value_info == "admin@localhost"

website_and_docs/content/documentation/webdriver/elements/information.en.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,10 @@ For this reason, Selenium has two precise methods to get these values: getDomAtt
264264
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L60-L71" >}}
265265
{{< /tab >}}
266266
{{< tab header="Python" text=true >}}
267-
{{< gh-codeblock path="/examples/python/tests/elements/test_information.py#L44-L46" >}}
267+
{{< gh-codeblock path="/examples/python/tests/elements/test_information.py#L44-L53" >}}
268268
{{< /tab >}}
269269
{{< tab header="CSharp" text=true >}}
270-
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L58-L62" >}}
270+
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L58-L69" >}}
271271
{{< /tab >}}
272272
{{< tab header="Ruby" text=true >}}
273273
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L48">}}
@@ -276,10 +276,18 @@ For this reason, Selenium has two precise methods to get these values: getDomAtt
276276
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L55-L68">}}
277277
{{< /tab >}}
278278
{{< tab header="Kotlin" >}}
279+
// FetchAttributes
279280
// Navigate to URL
280281
driver.get("https://www.selenium.dev/selenium/web/inputs.html")
281282

282-
//fetch the value property associated with the textbox
283+
// fetch the value property associated with the textbox
283284
val attr = driver.findElement(By.name("email_input")).getAttribute("value")
285+
286+
// New in Selenium 4.27+
287+
// fetches the DOM attribute exactly as written in the HTML source
288+
val domAttribute = driver.findElement(By.name("email_input")).getDomAttribute("name")
289+
290+
// fetches the live property value from the DOM object (may differ at runtime)
291+
val domProperty = driver.findElement(By.name("email_input")).getDomProperty("name")
284292
{{< /tab >}}
285293
{{< /tabpane >}}

0 commit comments

Comments
 (0)