How to get the attribute value of a web element in Selenium (using Java or Python)?

0 votes
How can I get the attribute value of a web element in Selenium (either by Python or Java)?
May 15 in Selenium by Umesh
104 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Hello @Umesh, if you want to get the attributes of a web element in Selenium you can use following code snippet:

1. For Java:

driver.findElement(By.xpath(".//div[contains(@class,'value')]")).getAttribute("attr_name");

2. For Python:

driver.find_element_by_xpath("/form/div[2]/div/div[3]/center/input[2]").get_attribute("attr_name")
answered May 15 by David

Related Questions In Selenium

0 votes
1 answer

Is it possible to manually set the attribute value of a Web Element using Selenium?

Yes, its very much possible. You just ...READ MORE

answered May 8, 2018 in Selenium by king_kenny
• 3,590 points
3,905 views
0 votes
1 answer
+1 vote
2 answers

How to get the title of a webpage using Selenium Java?

Essentially, driver.getTitle(); function can be used to ...READ MORE

answered Dec 17, 2018 in Selenium by Vardhan
• 11,050 points
98 views
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
164 views
0 votes
1 answer
0 votes
1 answer

What is the role of TestNG & JUnit frameworks in Selenium?

Well TestNG and JUnit are test frameworks ...READ MORE

answered Apr 18, 2018 in Selenium by king_kenny
• 3,590 points
158 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
555 views
0 votes
1 answer
0 votes
1 answer

How can I register webdrivers for python-selenium?

Hello Shelly, to register webdrivers like Chrome ...READ MORE

answered May 15 in Selenium by Pratibha
• 2,520 points
27 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.