I m not able to click on a button in a web page using selenium in python -
what wrong in below code
import os import time selenium import webdriver driver = webdriver.firefox() driver.get("http://x.x.x.x/html/load.jsp") elm1 = driver.find_element_by_link_text("load") time.sleep(10) elm1.click() time.sleep(30) driver.close()
the page source
<body> <div class="formcenterdiv"> <form class="form" action="../load" method="post"> <header class="formheader">loader</header> <div align="center"><button class="formbutton">load</button></div> </form> </div> </body></html>
i want click on button load. when ran above code getting error selenium.common.exceptions.nosuchelementexception: message: unable locate element: load
as documentation says, find_elements_by_link_text
works on a
tags:
use when know link text used within anchor tag. strategy, first element link text value matching location returned. if no element has matching link text attribute, nosuchelementexception raised.
the solution use different selector find_element_by_class_name
:
elm1 = driver.find_element_by_class_name('formbutton')
Comments
Post a Comment