1

trying to find a button that contains data-qa attribute. Try to handle it with following scheme:

x = browser.find_elements_by_css_selector("button[data-qa='deal-button']")
x[0].click()

As result getting an error:

IndexError: list index out of range

If I trying something like this:

button = (By.XPATH, "//button[@data-qa='deal-button']")
button.click()

There is another issue:

AttributeError: 'tuple' object has no attribute 'click'

What shall I do, to click on this button?

1 Answers1

0

IndexError: list index out of range probably means that x is an empty array. You can conditionally try clicking the button only if the button is present with something like this

if len(x) > 0:
    x[0].click()

What is probable is that you need to add a wait before the click because the element is not rendered yet. For further information I suggest this thread.

Mate Mrše
  • 7,997
  • 10
  • 40
  • 77