Q:

I want to check if a div has a specific ID and class robot framework

I want to check if the page contains an element with a specific id and a class:
${is_court_selected}=  Run Keyword And Return Status  Wait Until Page Contains Element  //div[@id="card_for_court_${position_1}",contains(@class,'selected_court_subtab_courts')]  ${TIMEOUT AJAX}

I get the following error code:

InvalidSelectorException: Message: Given xpath expression "//div[@id="card_for_court_15",contains(@class,'selected_court_subtab_courts')]" is invalid: SyntaxError: The expression is not a legal expression.

A:

At least add first locator strategy: xpath: //div[@id="card_for_court_${position_1}",contains(@class,'selected_court_subtab_courts')]
also you might need to replace the ,in xpath by and:
xpath: //div[@id="card_for_court_${position_1}" and contains(@class,'selected_court_subtab_courts')]

