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
254 views

1 answer to this question.

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
4,393 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,490 points
115 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
261 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
192 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
629 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,740 points
28 views