On a webpage, I have a button element with various attributes.
<button class="alert-area rj-button--plain ng-binding" ng-click="forceStructSync()" bs-tooltip="" data-original-title="This runs a structure sync, and makes sure our warehouse is aware of any new tables you've added to your database recently." data-placement="right" button-text="Check for new tables and columns"> <span class="rj-icon--refresh"></span> Check for new tables and columns </button>
I have tried with selenium with different forms of syntax to select and click the element using its button-text
attribute, but am unsure where the error is coming from. It is definitely not a timing issue, in other words, the page is loaded when the find command is executed.
from selenium import webdriver
driver = webdriver.Chrome()
import time
driver.get ('https://mywebsite.com')
#time.sleep(10)
driver.find_element_by_css_selector(".button[button-text='Check for new tables and columns']").click()
I have also tried the camel case buttonText
and button_text
in place button-text
, but this throws the same error.
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to lo
cate element: {"method":"css selector","selector":".button[button-text='Check for new tabl
es and columns']"}
Any suggestions on what might be the correct syntax here?