Reputation: 29
I have this element, and i want to change text inside class by Selenium driver from New York to Paris. How can i do that?
Element:
<a href="javascript:void(0);" class="get_city_select">New York</a>
This is my code but it doesn't work:
element = driver.find_element_by_class_name("get_city_select")
driver.execute_script("arguments[0].innerText = 'Paris'", element)
Thanks for help!
Upvotes: 2
Views: 1169
Reputation: 29362
If you want to change the attribute
, use the below code with specific xpath : //a[text()='New York']
code :
element = driver.find_element_by_xpath("//a[text()='New York']")
driver.execute_script("arguments[0].innerText = 'Paris'", element)
Upvotes: 1