0

My "view" button has the following element:

<a href="../a/stutransDet.php?sid=23" style="text-decoration: none;  FONT-SIZE: 1.0em;  color:black" target="">View Grade</a>

I selected the "view" button like this

view = driver.find_element_by_xpath("/html/body/div/div/div[2]/table/tbody/tr/td/table/tbody/tr[2]/td1/div[5]/a")
a = view.get_attribute('href')   # www.abc.com/a/stutransDet.php?sid=23

What I want is that I'll change the "href" of "view" so that when I click the "view" button, it will redirect to

 www.abc.com/a/stutransDet.php?sid=33 
instead of
www.abc.com/a/stutransDet.php?sid=23

Is this possible? this answer didn't work for me

Joseph Cho
  • 3,657
  • 4
  • 21
  • 32
Nitesh Tosniwal
  • 1,289
  • 2
  • 10
  • 15

1 Answers1

0

Try below solution to update @href value:

driver.execute_script('arguments[0].href = "www.abc.com/id=12";', view)
Andersson
  • 49,746
  • 15
  • 64
  • 117
  • @Nitesh , welcome. [Accept the answer](https://stackoverflow.com/help/accepted-answer) if it solved your issue – Andersson Oct 06 '18 at 16:26