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)?
6 days ago in Selenium by Umesh
16 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 6 days ago 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,202 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
• 10,570 points
68 views
0 votes
1 answer

How to scroll the Page up or down in Selenium WebDriver? (using java)

Its pretty simple. Check out the below ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,030 points
4,349 views
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,030 points
60 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
126 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
426 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 6 days ago in Selenium by Pratibha
• 2,520 points
23 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.