2

I have this HTML code:

<button ng-show="vm.loading_update" class="alert alert-warning">
  <strong>Upgrading firmware... Please Wait...</strong>
</button>

This alert message is open when a previous button was clicked (this is ok). So, I have this small code but doesn't work, the alert message isn't found.

self.elem = self.driver.find_element_by_xpath('//button[text()="Upgrade"]')
self.elem.click()
time.sleep(1)

WebDriverWait(self.driver, 2).until(EC.alert_is_present(),
                                     "Upgrading firmware... Please Wait...")
alert_test = self.driver.switch_to.alert()
alert_test.accept()

I need to know if this message is displayed to continue the test...

Thanks in advance.

1
  • Because this is not a standard alert. Commented Aug 6, 2018 at 14:26

1 Answer 1

2

Use the following code:

try:

    WebDriverWait(self.driver, 2).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".alert.alert-warning>strong")))

except:

    print("The alert is not displayed!")
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, it's working. And I will remove the "button" type, because doesn't make sense in this situation, because this alert message isn't a clickable item, is only information to user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.