Search code examples
pythonxmlselenium-webdriverxpath

SyntaxError: Document.evaluate: The expression is not a legal expression


I am being given the following error for my XPath definition:

selenium.common.exceptions.InvalidSelectorException: Message: Given xpath expression ..... is invalid: SyntaxError: Document.evaluate: The expression is not a legal expression

The expression is defined below:

total_games = driver.find_elements(By.XPATH, '//div[@class="mb5"]/div/div/div/div/div/table/tbody/tr[@data-idx and not @class="totals_row fw-bold ttu Table__TR Table__TR--sm Table__even"]')

What did I do wrong?


Solution

  • not @class="totals_row fw-bold ttu Table__TR Table__TR--sm Table__even"
    

    should be

    not(@class="totals_row fw-bold ttu Table__TR Table__TR--sm Table__even")