MCPcopy
hub / github.com/InstaPy/InstaPy / get_page_title

Function get_page_title

instapy/util.py:2014–2036  ·  view source on GitHub ↗

Get the title of the webpage

(browser, logger)

Source from the content-addressed store, hash-verified

2012
2013
2014def 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
2039def click_visibly(browser, element):

Callers 1

is_page_availableFunction · 0.85

Calls 2

explicit_waitFunction · 0.85
execute_scriptMethod · 0.80

Tested by

no test coverage detected