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()
Jonny
  • 241
  • 3
  • 10

1 Answers1

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.

Xosrov
  • 719
  • 4
  • 22
  • 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

    – Jonny Jun 07 '19 at 21:11
  • 1
    @Jonny [take a look at this](https://stackoverflow.com/a/47469615/7764138). Pick an element by clicking on the mouse cursor over square symbol. There should be tutorials for that online :) – Xosrov Jun 07 '19 at 21:17