1

On the following page, I want to click the text "Mietpreise" with selenium. https://www.homeday.de/de/preisatlas

I tried different things, but did not get it work. Latest source is:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("https://www.homeday.de/de/preisatlas")

driver.find_element_by_class_name("filter-switcher__item").click()

1 Answer 1

1

You can try using the Xpath of the element, which you find by using "Inspect Element" on the button, and right clicking the snippet of code to copy the Xpath:

from selenium import webdriver
browser = webdriver.Firefox()
browser.get("https://www.homeday.de/de/preisatlas")
browser.find_element_by_xpath("/html/body/div[1]/div/div/div/main/section/div[2]/div[1]/form/div[2]/p[2]").click()

It uses an absolute path and doesn't require much work to acquire.

Sign up to request clarification or add additional context in comments.

2 Comments

Yeah, that works, wow, thank you very much!! How exactly do I get the Xpath? I use "Inspect Element", when I right click on the code <p class="..., I do not find anything to copy the Xpath...
@Jonny take a look at this. Pick an element by clicking on the mouse cursor over square symbol. There should be tutorials for that online :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.