I am verifying if some text is present in my element. The text includes a quote in the string. My method is asserting False. I am expecting it to be True because the text is there on the GUI.
I am not including the quote properly in the string. What is the correct syntax please?
When i inspect the code using the debugger it says:
overwritten_element.text = {unicode} u'One or more reports use the \\'default\\'prefix and will be overwritten. Do you wish to continue?
My method is:
def is_save_overwrite_dialog_displayed(self):
overwritten_element = self.get_element(By.ID, 'message_dialog_question_content')
return overwritten_element.text == r"One or more reports use the 'default' prefix and will be overwritten. Do you wish to continue?"
The string with the quote is: One or more reports use the 'default' prefix and will be overwritten. Do you wish to continue?
I have tried
r"One or more reports use the 'default' prefix and will be overwritten. Do you` wish to continue?"
and I have tried:
r"One or more reports use the \\'default\\' prefix and will be overwritten. Do you wish to continue?"
The HTML is:
<div id="message_dialog_question_content">
<div>One or more reports use the 'default' prefix and will be overwritten. Do you wish to continue?</div>
</div>
get_element
# returns the element if found
def get_element(self, how, what):
# params how: By locator type
# params what: locator value
try:
element = self.driver.find_element(by=how, value=what)
except NoSuchElementException, e:
print what
print "Element not found "
print e
screenshot_name = how + what + get_datetime_now() # create screenshot name of the name of the element + locator + todays date time. This way the screenshot name will be unique and be able to save
self.save_screenshot(screenshot_name)
raise
return element
Thanks, Riaz