I want to automatically click on an element in a web page using the following code in Python:
driver.find_element_by_id("book appointment").click()
The web page snapshot is as follows:
My problem is that I cannot find "Book Appointment" text in the page source to extract its ID. How can I find its ID?
The HTML code provided by you doesn't contains any Id attribute for this element, so it is not possible to locate the element by ID. Alternatively, you can locate the element with text using an XPath selector. Try the below code to locate the same:
driver.find_element_by_xpath("//a[contains(.,'Book Appointment')]")