This is the HTML
<button type="button" class="d-block p-3 mx-auto btn btn-danger btn-lg xh-highlight">
<i class="fa fa-close mr-1">
</i>
Close
</button>
And I'm trying with:
driver.find_element(By.XPATH, "//button[@class = 'd-block p-3 mx-auto btn btn-danger btn-lg']").click()
driver.find_element(By.CLASS_NAME,"d-block").click()
print driver.find_element(By.XPATH, "//button[contains(text(), 'Close')]").click()
driver.find_element(By.XPATH, "//button[@type = 'button' and contains(text(), 'Close')]").click()
This is the error I'm getting
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//button[@class = 'd-block p-3 mx-auto btn btn-danger btn-lg']"}
(Session info: chrome=70.0.3538.110)
(Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 10.0.17134 x86_64)