0
element = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="liveAgentChatLogText"]//*[contains(string(.), "THE_TEXT_STRING_I_AM_LOOKING_FOR")]')

driver.find_element_by_xpath('//*[@id="contactFirstName"]').send_keys(firstName)
driver.find_element_by_xpath('//*[@id="contactLastName"]').send_keys(lastName)

This one would say for an example, it'd say "SyntaxError: invalid syntax", the second one.

element = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="liveAgentChatLogText"]//*[contains(string(.), "THE_TEXT_STRING_I_AM_LOOKING_FOR")]')

SyntaxError: unexpected EOF while parsing

So, I really have no clue what to do, everything that's underneath the code, says invalid syntax, and if it's above it says unexpected EOF...

  • What is the value of THE_TEXT_STRING_I_AM_LOOKING_FOR? Share the xpath that is actually used in runtime? – Alexey R. Sep 5 '18 at 13:53
  • @AlexeyR. element = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="liveAgentChatLogText"]//*[contains(string(.), "THE_TEXT_STRING_I_AM_LOOKING_FOR")]') driver.find_element_by_xpath('//*[@id="contactFirstName"]').send_keys(firstName) driver.find_element_by_xpath('//*[@id="contactLastName"]').send_keys(lastName) This one would say for an example, it'd say "SyntaxError: invalid syntax", the second one. So, I really have no clue what to do, everything that's underneath the code, says invalid syntax, and if it's above it says unexpected EOF... – Den Sep 5 '18 at 14:18
0

You have the broken syntax of the entire expression. You should change single quote to double quote and close your expression with )]'). Your line should look like:

driver.find_element(By.XPATH, '//*[@id="liveAgentChatLogText"]//*[contains(string(.), "THE_TEXT_STRING_I_AM_LOOKING_FOR")]')

You should also be aware of you can break the syntax if your THE_TEXT_STRING_I_AM_LOOKING_FOR will include some special characters like quotes.

  • With this code though now, whatever I put underneath it, it says invalid syntax "driver.find_element_by_xpath('//*[@id="liveAgentChatInput"]').send_keys("TEST"):" – Den Sep 5 '18 at 14:10
  • Also, when I put only the code you gave me, it says SyntaxError: unexpected EOF while parsing. – Den Sep 5 '18 at 14:13
  • This should help you stackoverflow.com/questions/5074225/… – Alexey R. Sep 5 '18 at 14:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.