0

I am trying to click on save button. I am using firefox. I have tried below target in firefox IDE which is working as expected there

css=div.ui-dialog-buttonset button:contains('Yes, ')

However, When I am trying to find it in python using below command, it is failing

element = div.ui-dialog-buttonset button:contains('Yes, ')
my_driver.find_element_by_css_selector(element).click()

I am getting below error

 raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidSelectorException: Message: Given css selector expression "div.ui-dialog-buttonset button:contains('Yes, ')" is invalid: InvalidSelectorError: 'div.ui-dialog-buttonset button:contains('Yes, ')' is not a valid selector: "div.ui-dialog-buttonset button:contains('Yes, ')"

Any clues. What is the respective xpath value

4
  • 1
    Possible duplicate of selenium.common.exceptions.InvalidSelectorException Commented Dec 20, 2017 at 7:13
  • Using css contains is dangerous. I have seen it fail in many cases. Commented Dec 20, 2017 at 7:15
  • Could you pls provide the structure of the button? HTML and CSS. Commented Dec 20, 2017 at 7:16
  • contains function is not supported in selenium css selector. Commented Dec 20, 2017 at 7:22

1 Answer 1

1

You can use xpath for this

browser.find_element_by_xpath("//div[contains(@class, 'ui-dialog-buttonset')]/button[contains(text(),'Yes, ')]")
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.