我的“查看”按钮具有以下元素:
<a href="../a/stutransDet.php?sid=23" style="text-decoration: none; FONT-SIZE: 1.0em; color:black" target="">View Grade</a>
我选择了这样的“查看”按钮
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
我想要的是更改“视图”的“ href”,以便当我单击“视图”按钮时,它将重定向到
www.abc.com/a/stutransDet.php?sid=33而不是{{2} }
这可能吗? this answer不适用于我
答案 0 :(得分:0)
请尝试以下解决方案来更新@href
的值:
driver.execute_script('arguments[0].href = "www.abc.com/id=12";', view)