Get the title of the webpage
(browser, logger)
| 2012 | |
| 2013 | |
| 2014 | def get_page_title(browser, logger): |
| 2015 | """Get the title of the webpage""" |
| 2016 | # wait for the current page fully load to get the correct page's title |
| 2017 | explicit_wait(browser, "PFL", [], logger, 10) |
| 2018 | |
| 2019 | try: |
| 2020 | page_title = browser.title |
| 2021 | |
| 2022 | except WebDriverException: |
| 2023 | try: |
| 2024 | page_title = browser.execute_script("return document.title") |
| 2025 | |
| 2026 | except WebDriverException: |
| 2027 | try: |
| 2028 | page_title = browser.execute_script( |
| 2029 | "return document.getElementsByTagName('title')[0].text" |
| 2030 | ) |
| 2031 | |
| 2032 | except WebDriverException: |
| 2033 | logger.info("Unable to find the title of the page :(") |
| 2034 | return None |
| 2035 | |
| 2036 | return page_title |
| 2037 | |
| 2038 | |
| 2039 | def click_visibly(browser, element): |
no test coverage detected