0

Using this code :

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


browser = webdriver.Firefox()
browser.get('http://www.booking.com')  
browser.find_element_by_id('ss').send_keys("Galway")
browser.find_element_by_class_name('xp__dates-inner').click()
browser.find_element_by_css_selector('data-date=2019-05-14').click()

I'm attempting to select the element data-date="2019-05-14"

But receive exception :

InvalidSelectorException: Message: Given css selector expression "data-date=2019-05-14" is invalid: InvalidSelectorError: 'data-date=2019-05-14' is not a valid selector: "data-date=2019-05-14"

Have I set the id of the selector correctly?

1

1 Answer 1

1

You were close.However when use any attribute with css selector you have to use parathesis [attribute="value"] excluding id and class. However you can use id and class without parenthesis.

browser.find_element_by_css_selector('[data-date="2019-05-14"]').click()
Sign up to request clarification or add additional context in comments.

Comments

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.