Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public void informationWithElements() {
String valueInfo = emailTxt.getAttribute("value");
assertEquals(valueInfo,"admin@localhost");

// Fetch Dom Property
String propInfo = emailTxt.getDomProperty("value");
assertEquals(propInfo,"admin@localhost");

// Fetch Dom Attribute
String attrInfo = emailTxt.getDomAttribute("value");
assertEquals(attrInfo,"admin@localhost");

driver.quit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ val text = driver.findElement(By.id("justanotherlink")).getText()



## Fetching Attributes or Properties
## Fetching Attributes and Properties

### Get Attribute
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be we need to be more precise now with the difeerences between getAtrribute, getDomAttribute and getDomProperty

example:

Returns the element's property value if present, otherwise falls back to the attribute value. This convenience method handles the common case but can be ambiguous. For precise control, use getDomProperty() or getDomAttribute() instead.

@diemol any thoughts !

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are showing in here how to use it. Let me know if any changes are needed at code level?

Copy link
Contributor

@sbabcoc sbabcoc Nov 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harsha509 getAttribute() is actually deprecated for just that reason.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including a synopsis of this information would be helpful: What's the difference between an "attribute" and a "property" in the DOM? | Quiz Interview Questions with Solutions https://share.google/lB3bUx9KDK28LOx9B

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sbabcoc,

I’m already aware of the distinction, this is exactly why I asked for the documentation to clearly outline the difference in a way users can understand.

Also getAtrribute is not deprecated yet in selenium see https://github.com/SeleniumHQ/selenium/blob/trunk/java/CHANGELOG

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are showing in here how to use it. Let me know if any changes are needed at code level?

HI @rpallavisharma ,

Not in the code samples, i was referring to documentation.
so currently in docs for getAtrribute we have

Fetches the run time value associated with a DOM attribute. It returns the data associated with the DOM attribute or property of the element.

we can change to

Returns the element's property value if present, otherwise falls back to the attribute value. This convenience method handles the common case but can be ambiguous. For precise control, use getDomProperty() or getDomAttribute() instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harsha509 in this PR, i haven't acted on the existing part of documentation. i have added the new methods. please evaluate this PR on that basis. if the information is correct, which it is according to my understading in the document and code, kindly accept the PR.
i believe what you are saying is modifying an existing definition. which this PR doesn't do.
kindly let me know.


Fetches the run time value associated with a
DOM attribute. It returns the data associated
Expand Down Expand Up @@ -281,3 +283,55 @@ driver.get("https://www.selenium.dev/selenium/web/inputs.html")
val attr = driver.findElement(By.name("email_input")).getAttribute("value")
{{< /tab >}}
{{< /tabpane >}}


### Get Dom Property

This method retrieves the value of a specific DOM property of a web element.

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L67-L69" >}}
{{< /tab >}}
{{< tab header="Python" text=true >}}

{{< /tab >}}
{{< tab header="CSharp" text=true >}}

{{< /tab >}}
{{< tab header="Ruby" text=true >}}

{{< /tab >}}
{{< tab header="JavaScript" text=true >}}

{{< /tab >}}
{{< tab header="Kotlin" >}}

{{< /tab >}}
{{< /tabpane >}}


### Get Dom Attribute

This method retrieves the value of a specific HTML attribute of a web element

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L71-L73" >}}
{{< /tab >}}
{{< tab header="Python" text=true >}}

{{< /tab >}}
{{< tab header="CSharp" text=true >}}

{{< /tab >}}
{{< tab header="Ruby" text=true >}}

{{< /tab >}}
{{< tab header="JavaScript" text=true >}}

{{< /tab >}}
{{< tab header="Kotlin" >}}

{{< /tab >}}
{{< /tabpane >}}
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ val text = driver.findElement(By.id("justanotherlink")).getText()
{{< /tab >}}
{{< /tabpane >}}

## Fetching Attributes or Properties
## Fetching Attributes and Properties

### Get Attribute

Fetches the run time value associated with a
DOM attribute. It returns the data associated
Expand All @@ -265,13 +267,64 @@ with the DOM attribute or property of the element.
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L55-L59">}}
{{< /tab >}}
{{< tab header="Kotlin" >}}

{{< tab header="Kotlin" >}}
// Navigate to URL
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

//fetch the value property associated with the textbox
val attr = driver.findElement(By.name("email_input")).getAttribute("value")
{{< /tab >}}
{{< /tabpane >}}


### Get Dom Property

This method retrieves the value of a specific DOM property of a web element.

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L67-L69" >}}
{{< /tab >}}
{{< tab header="Python" text=true >}}

{{< /tab >}}
{{< tab header="CSharp" text=true >}}

{{< /tab >}}
{{< tab header="Ruby" text=true >}}

{{< /tab >}}
{{< tab header="JavaScript" text=true >}}

{{< /tab >}}
{{< tab header="Kotlin" >}}

{{< /tab >}}
{{< /tabpane >}}


### Get Dom Attribute

This method retrieves the value of a specific HTML attribute of a web element

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L71-L73" >}}
{{< /tab >}}
{{< tab header="Python" text=true >}}

{{< /tab >}}
{{< tab header="CSharp" text=true >}}

{{< /tab >}}
{{< tab header="Ruby" text=true >}}

{{< /tab >}}
{{< tab header="JavaScript" text=true >}}

{{< /tab >}}
{{< tab header="Kotlin" >}}

{{< /tab >}}
{{< /tabpane >}}

Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,21 @@ val text = driver.findElement(By.id("justanotherlink")).getText()
{{< /tab >}}
{{< /tabpane >}}

## Fetching Attributes or Properties
## Fetching Attributes and Properties

### Get Attribute

Fetches the run time value associated with a
DOM attribute. It returns the data associated
with the DOM attribute or property of the element.

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L60-L65" >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L60-L64" >}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="/examples/python/tests/elements/test_information.py#L44-L46" >}}
{{< /tab >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L58-L62" >}}
{{< /tab >}}
Expand All @@ -280,13 +282,63 @@ with the DOM attribute or property of the element.
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L55-L59">}}
{{< /tab >}}
{{< tab header="Kotlin" >}}

{{< tab header="Kotlin" >}}
// Navigate to URL
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

//fetch the value property associated with the textbox
val attr = driver.findElement(By.name("email_input")).getAttribute("value")
{{< /tab >}}
{{< /tabpane >}}


### Get Dom Property

This method retrieves the value of a specific DOM property of a web element.

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L67-L69" >}}
{{< /tab >}}
{{< tab header="Python" text=true >}}

{{< /tab >}}
{{< tab header="CSharp" text=true >}}

{{< /tab >}}
{{< tab header="Ruby" text=true >}}

{{< /tab >}}
{{< tab header="JavaScript" text=true >}}

{{< /tab >}}
{{< tab header="Kotlin" >}}

{{< /tab >}}
{{< /tabpane >}}


### Get Dom Attribute

This method retrieves the value of a specific HTML attribute of a web element

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L71-L73" >}}
{{< /tab >}}
{{< tab header="Python" text=true >}}

{{< /tab >}}
{{< tab header="CSharp" text=true >}}

{{< /tab >}}
{{< tab header="Ruby" text=true >}}

{{< /tab >}}
{{< tab header="JavaScript" text=true >}}

{{< /tab >}}
{{< tab header="Kotlin" >}}

{{< /tab >}}
{{< /tabpane >}}
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,55 @@ val attr = driver.findElement(By.name("email_input")).getAttribute("value")

{{< /tab >}}
{{< /tabpane >}}


### Get Dom Property

This method retrieves the value of a specific DOM property of a web element.

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L67-L69" >}}
{{< /tab >}}
{{< tab header="Python" text=true >}}

{{< /tab >}}
{{< tab header="CSharp" text=true >}}

{{< /tab >}}
{{< tab header="Ruby" text=true >}}

{{< /tab >}}
{{< tab header="JavaScript" text=true >}}

{{< /tab >}}
{{< tab header="Kotlin" >}}

{{< /tab >}}
{{< /tabpane >}}


### Get Dom Attribute

This method retrieves the value of a specific HTML attribute of a web element

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L71-L73" >}}
{{< /tab >}}
{{< tab header="Python" text=true >}}

{{< /tab >}}
{{< tab header="CSharp" text=true >}}

{{< /tab >}}
{{< tab header="Ruby" text=true >}}

{{< /tab >}}
{{< tab header="JavaScript" text=true >}}

{{< /tab >}}
{{< tab header="Kotlin" >}}

{{< /tab >}}
{{< /tabpane >}}
Loading