Probably a silly question, but I have spent a ridiculous amount of time trying to figure this out. I am building a scrapper bot using selenium in python, and I am just trying to click a button on a web page. The web page opens and resizes...
def initalize_browser():
driver.get("**website name**")
driver.maximize_window()
but I cannot get it to click a specific button. This is the buttons HTML code:
<button class="mx-auto green-btn btnHref" onclick="window.location ='/medical'" onkeypress="window.location='/medical'">
Medical and Hospital Costs
</button>
And this is my code:
click_button=driver.find_element(by=By.CLASS_NAME, value="mx-auto green-btn btnHref")
click_button.click()
This is the error I get for this code:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".mx-auto green-btn btnHref"}
I have tried out so many variations of this, including:
driver.find_element_by_xpath('//button[@class="mx-auto green-btn btnHref"]').click()
Where I get this error:
AttributeError: 'WebDriver' object has no attribute 'find_element_by_xpath'
I have also checked to see if there are perhaps any other attributes with the same class name, but there is not. Any help would be super appreciated, thank you!
find_element_by_xpathcall return?<iframe>tag inside it?