Python selenium.common.exceptions.WebDriverException() Examples

The following are 30 code examples of selenium.common.exceptions.WebDriverException(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module selenium.common.exceptions , or try the search function .
Example #1
Source File: utils.py    From CumulusCI with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
def selenium_execute_with_retry(self, execute, command, params):
        """Run a single selenium command and retry once.

        The retry happens for certain errors that are likely to be resolved
        by retrying.
        """
        try:
            return execute(command, params)
        except Exception as e:
            if isinstance(e, ALWAYS_RETRY_EXCEPTIONS) or (
                isinstance(e, WebDriverException)
                and "Other element would receive the click" in str(e)
            ):
                # Retry
                self.builtin.log("Retrying {} command".format(command), level="WARN")
                time.sleep(2)
                return execute(command, params)
            else:
                raise 
Example #2
Source File: comment_util.py    From bot with GNU General Public License v3.0 6 votes vote down vote up
def open_comment_section(browser, logger):
    missing_comment_elem_warning = (
        "--> Comment Button Not Found!"
        "\t~may cause issues with browser windows of smaller widths"
    )

    comment_elem = browser.find_elements_by_xpath(
        read_xpath(open_comment_section.__name__, "comment_elem")
    )

    if len(comment_elem) > 0:
        try:
            click_element(browser, comment_elem[0])
            return True

        except WebDriverException:
            logger.warning(missing_comment_elem_warning)

    else:
        logger.warning(missing_comment_elem_warning)
    return False 
Example #3
Source File: helpers.py    From winnaker with MIT License 6 votes vote down vote up
def click_stubborn(driver, e, xpath):
    logging.debug("Starting stubborn clicks")
    MAX_ATTEMPT = 6
    attempt = 0
    while attempt < MAX_ATTEMPT:
        try:
            for i in range(10):
                attempt += 1
                e.click()
                break
            # breaks if no exception happens
            break
        except StaleElementReferenceException:
            a_nice_refresh(driver)
            e = wait_for_xpath_presence(driver, xpath)
        except WebDriverException:
            break
    return e 
Example #4
Source File: node.py    From capybara.py with MIT License 6 votes vote down vote up
def click(self, *keys, **offset):
        try:
            if not any(keys) and not self._has_coords(offset):
                self.native.click()
            else:
                @self._scroll_if_needed
                def click():
                    with self._action_with_modifiers(keys, offset) as a:
                        a.click() if self._has_coords(offset) else a.click(self.native)
                click()

        except WebDriverException as e:
            if (
                # Marionette
                isinstance(e, ElementClickInterceptedException) or

                # Chrome
                "Other element would receive the click" in e.msg
            ):
                self._scroll_to_center()

            raise 
Example #5
Source File: browser_mgmt.py    From warriorframework with Apache License 2.0 6 votes vote down vote up
def go_to(self, url, browser_instance=None):
        """Navigates the active browser instance to the provided URL."""
        status = True
        try:
            print_info("Opening url '%s'" % url)
            if browser_instance is not None:
                browser_instance.get(url)
            else:
                self.current_browser.get(url)
        except WebDriverException as err:
            print_error(err)
            if "Reached error page" in str(err):
                print_error("Unable to Navigate to URL:{}"\
                            "possibly because of the url is not valid".format(url))
            else:
                status = False
        except Exception, err:
            print_error(err)
            status = False
            print_error("Unable to Navigate to URL:'%s'" % url)
            traceback.print_exc() 
Example #6
Source File: hibp.py    From ODIN with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def paste_check(self,email):
        """Check for the target's email in pastes across multiple paste websites. This includes
        sites like Slexy, Ghostbin, Pastebin using HIBP's API.

        Parameters:
        email       The email address to look-up in Have I Been Pwned's pastes database
        """
        try:
            self.browser.get(self.hibp_paste_uri.format(email))
            # cookies = browser.get_cookies()
            json_text = self.browser.find_element_by_css_selector('pre').get_attribute('innerText')
            pastes = json.loads(json_text)
            return pastes
        except TimeoutException:
            click.secho("[!] The connection to HaveIBeenPwned timed out!",fg="red")
            return []
        except NoSuchElementException:
            # This is likely an "all clear" -- no hits in HIBP
            return []
        except WebDriverException:
            return [] 
Example #7
Source File: hibp.py    From ODIN with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def pwn_check(self,email):
        """Check for the target's email in public security breaches using HIBP's API.

        Parameters:
        email       The email address to look-up in Have I Been Pwned's breach database
        """
        try:
            self.browser.get(self.hibp_breach_uri.format(email))
            # cookies = browser.get_cookies()
            json_text = self.browser.find_element_by_css_selector('pre').get_attribute('innerText')
            pwned = json.loads(json_text)
            return pwned
        except TimeoutException:
            click.secho("[!] The connection to HaveIBeenPwned timed out!",fg="red")
            return []
        except NoSuchElementException:
            # This is likely an "all clear" -- no hits in HIBP
            return []
        except WebDriverException:
            return [] 
Example #8
Source File: plugin.py    From robotframework-seleniumtestability with Apache License 2.0 6 votes vote down vote up
def get_log(self: "SeleniumTestability", log_type: str = "browser") -> BrowserLogsType:
        """
        Returns logs determined by ``log_type`` from the current browser. What is returned
        depends on desired_capabilities passed to `Open Browser`.

        Note: On firefox, the firefox profile has to have `devtools.console.stdout.content` property to be set.
        This can be done automatically with `Generate Firefox Profile` and then pass that to `Open Browser`.

        This keyword will mostly likely not work with remote seleniun driver!
        """
        ret = []  # type: BrowserLogsType
        try:
            if is_firefox(self.ctx.driver) and log_type == "browser":
                ret = self._get_ff_log(self.ctx.driver.service.log_file.name)
            else:
                ret = self.ctx.driver.get_log(log_type)
        except WebDriverException:
            if not self.browser_warn_shown:
                self.browser_warn_shown = True
                self.warn("Current browser does not support fetching logs from the browser with log_type: {}".format(log_type))
                return []
        if not ret and not self.empty_log_warn_shown:
            self.empty_log_warn_shown = True
            self.warn("No logs available - you might need to enable loggingPrefs in desired_capabilities")
        return ret 
Example #9
Source File: util.py    From micromasters with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def click_when_loaded(self, by, value, retries=DEFAULT_RETRY_COUNT):
        """
        Helper method to tell the driver to wait until an element is loaded, then click it.
        Since clicking on page elements is the most common source of test flakiness in our selenium suite, this
        includes some functionality for retrying the click some number of times if specific exceptions are raised.
        """
        retries_remaining = retries
        wait = self.wait()
        while True:
            try:
                return wait.until(
                    lambda driver: driver.find_element(by, value)
                ).click()
            except WebDriverException:
                if retries_remaining > 0:
                    retries_remaining -= 1
                else:
                    raise 
Example #10
Source File: utils.py    From opencraft with GNU Affero General Public License v3.0 6 votes vote down vote up
def setUp(self):
        """
        Start firefox.
        """
        super().setUp()
        site = Site.objects.get()
        site.name = 'testing'
        site.domain = self.live_server_url.split('//')[1]
        site.save()
        options = Options()
        options.headless = True
        # Ensure we don't attempt to use the new geckodriver method (which
        # isn't working for us. I _think_ selenium 2 defaults to old method,
        # but just to make sure.
        cap = DesiredCapabilities().FIREFOX
        cap['marionette'] = False
        try:
            self.client = webdriver.Firefox(capabilities=cap, firefox_options=options)
        except WebDriverException:
            time.sleep(1)
            self.client = webdriver.Firefox(capabilities=cap, firefox_options=options) 
Example #11
Source File: browser.py    From bot with GNU General Public License v3.0 6 votes vote down vote up
def close_browser(browser, threaded_session, logger):
    with interruption_handler(threaded=threaded_session):
        # delete cookies
        try:
            browser.delete_all_cookies()
        except Exception as exc:
            if isinstance(exc, WebDriverException):
                logger.exception(
                    "Error occurred while deleting cookies "
                    "from web browser!\n\t{}".format(str(exc).encode("utf-8"))
                )

        # close web browser
        try:
            browser.quit()
        except Exception as exc:
            if isinstance(exc, WebDriverException):
                logger.exception(
                    "Error occurred while "
                    "closing web browser!\n\t{}".format(str(exc).encode("utf-8"))
                ) 
Example #12
Source File: comment_util.py    From FacebookPy with GNU General Public License v3.0 6 votes vote down vote up
def open_comment_section(browser, logger):
    missing_comment_elem_warning = (
        "--> Comment Button Not Found!"
        "\t~may cause issues with browser windows of smaller widths"
    )

    comment_elem = browser.find_elements_by_xpath(
        "//button/span[@aria-label='Comment']"
    )

    if len(comment_elem) > 0:
        try:
            click_element(browser, Settings, comment_elem[0])

        except WebDriverException:
            logger.warning(missing_comment_elem_warning)

    else:
        logger.warning(missing_comment_elem_warning) 
Example #13
Source File: util.py    From bot with GNU General Public License v3.0 6 votes vote down vote up
def get_page_title(browser, logger):
    """ Get the title of the webpage """
    # wait for the current page fully load to get the correct page's title
    explicit_wait(browser, "PFL", [], logger, 10)

    try:
        page_title = browser.title

    except WebDriverException:
        try:
            page_title = browser.execute_script("return document.title")

        except WebDriverException:
            try:
                page_title = browser.execute_script(
                    "return document.getElementsByTagName('title')[0].text"
                )

            except WebDriverException:
                logger.info("Unable to find the title of the page :(")
                return None

    return page_title 
Example #14
Source File: util.py    From bot with GNU General Public License v3.0 6 votes vote down vote up
def getUserData(
    query,
    browser,
    basequery="return window.__additionalData[Object.keys(window.__additionalData)[0]].data.",
):
    try:
        data = browser.execute_script(basequery + query)
        return data
    except WebDriverException:
        browser.execute_script("location.reload()")
        update_activity(browser, state=None)

        data = browser.execute_script(
            "return window._sharedData." "entry_data.ProfilePage[0]." + query
        )
        return data 
Example #15
Source File: util.py    From bot with GNU General Public License v3.0 6 votes vote down vote up
def get_number_of_posts(browser):
    """Get the number of posts from the profile screen"""
    try:
        num_of_posts = getUserData(
            "graphql.user.edge_owner_to_timeline_media.count", browser
        )
    except WebDriverException:
        try:
            num_of_posts_txt = browser.find_element_by_xpath(
                read_xpath(get_number_of_posts.__name__, "num_of_posts_txt")
            ).text

        except NoSuchElementException:
            num_of_posts_txt = browser.find_element_by_xpath(
                read_xpath(
                    get_number_of_posts.__name__, "num_of_posts_txt_no_such_element"
                )
            ).text

        num_of_posts_txt = num_of_posts_txt.replace(" ", "")
        num_of_posts_txt = num_of_posts_txt.replace(",", "")
        num_of_posts = int(num_of_posts_txt)

    return num_of_posts 
Example #16
Source File: base_page.py    From webium with Apache License 2.0 5 votes vote down vote up
def is_element_present(self, element_name, just_in_dom=False, timeout=0):
    def _get_driver():
        try:
            driver = getattr(self, '_driver')
        except AttributeError:
            driver = getattr(self, 'parent', None)
        if driver:
            return driver
        return get_driver()

    _get_driver().implicitly_wait(timeout)
    try:
        def is_displayed():
            try:
                element = getattr(self, element_name)
            except AttributeError:
                raise WebiumException('No element "{0}" within container {1}'.format(element_name, self))
            if isinstance(element, list):
                if element:
                    return all(ele.is_displayed() for ele in element)
                else:
                    return False
            return element.is_displayed()

        is_displayed() if just_in_dom else wait(lambda: is_displayed(), timeout_seconds=timeout)
        return True
    except WebDriverException:
        return False
    except TimeoutExpired:
        return False
    finally:
        _get_driver().implicitly_wait(webium.settings.implicit_timeout) 
Example #17
Source File: window.py    From nerodia with MIT License 5 votes vote down vote up
def _matches(self, handle):
        try:
            orig = self.driver.current_window_handle
        except NoSuchWindowException:
            orig = None
        try:
            self.driver.switch_to.window(handle)

            if 'title' in self.selector:
                title_value = self.selector.get('title')
                driver_title = self.browser.title
                matches_title = re.search(title_value, driver_title) is not None
            else:
                matches_title = True

            if 'url' in self.selector:
                url_value = self.selector.get('url')
                driver_url = self.browser.url
                matches_url = re.search(url_value, driver_url) is not None
            else:
                matches_url = True

            return matches_title and matches_url
        except (NoSuchWindowException, WebDriverException):
            return False
        finally:
            current = self.driver.window_handles
            orig = orig if orig in current else current[0]
            self.driver.switch_to.window(orig) 
Example #18
Source File: wait.py    From webium with Apache License 2.0 5 votes vote down vote up
def wait(*args, **kwargs):
    """
    Wrapping 'wait()' method of 'waiting' library with default parameter values.
    WebDriverException is ignored in the expected exceptions by default.
    """
    kwargs.setdefault('sleep_seconds', (1, None))
    kwargs.setdefault('expected_exceptions', WebDriverException)
    kwargs.setdefault('timeout_seconds', webium.settings.wait_timeout)

    return wait_lib(*args, **kwargs) 
Example #19
Source File: element_tests.py    From nerodia with MIT License 5 votes vote down vote up
def test_returns_true_if_element_center_is_covered_by_non_descendant(self, browser):
        btn = browser.button(id='obscured')
        assert btn.obscured
        exception = WebDriverException if browser.name == 'chrome' else \
            ElementClickInterceptedException
        with pytest.raises(exception):
            btn.click() 
Example #20
Source File: webdriver.py    From avos with Apache License 2.0 5 votes vote down vote up
def __init__(self, firefox_profile=None, firefox_binary=None,
                     timeout=30, capabilities=None, proxy=None):
            try:
                super(WebDriver, self).__init__(
                    firefox_profile, FirefoxBinary(), timeout, capabilities,
                    proxy)
            except selenium_exceptions.WebDriverException:
                # If we can't start, cleanup profile
                shutil.rmtree(self.profile.path)
                if self.profile.tempfolder is not None:
                    shutil.rmtree(self.profile.tempfolder)
                raise 
Example #21
Source File: scihub.py    From scihub2pdf with GNU Affero General Public License v3.0 5 votes vote down vote up
def start(self):
        try:
            self.s = requests.Session()
            self.driver = webdriver.PhantomJS()
        except WebDriverException:
            print("\n\t Install PhantomJS for download files in sci-hub.\n")
            print("\t OSX:")
            print("\t\t npm install -g phantomjs")
            print("\n\t Linux with npm:")
            print("\t\t sudo apt-get install npm\n")
            print("\t\t sudo npm install -g phantomjs\n")

            sys.exit(1) 
Example #22
Source File: selenium_tests.py    From polemarch with GNU Affero General Public License v3.0 5 votes vote down vote up
def test_qunit(self):
        selenium = self.selenium
        # Opening the link we want to test
        selenium.get('http://localhost:8888/')
        login = selenium.find_element_by_name('username')
        login.send_keys('admin')
        password = selenium.find_element_by_name('password')
        password.send_keys('admin')
        submit = selenium.find_element_by_id('login_button')
        submit.send_keys(Keys.RETURN)
        trys = 40
        for i in range(trys):
            try:
                selenium.execute_script('window.loadQUnitTests()')
                trys = 300
                break
            except exceptions.WebDriverException:
                log_data = selenium.get_log('browser')
                if log_data:
                    print(log_data)
                sleep(1)
                trys -= 1
            finally:
                self.assertTrue(trys > 0, trys)
        saveReportObj = None
        for _ in range(900):
            try:
                saveReportObj = selenium.find_element_by_id('qunit-saveReport')
            except exceptions.NoSuchElementException:
                log_data = selenium.get_log('browser')
                if log_data:
                    print(log_data)
                sleep(1)
            else:
                break
        self.assertNotEqual(saveReportObj, None) 
Example #23
Source File: screenshots.py    From ODIN with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def take_screenshot(self,target,directory):
        """Function to take a screenshot of a target webpage.

        Parameters:
        target      The IP address or domain name to use for the web request
        directory   The directory where the saved screenshots will be stored
        """
        try:
            out_name = target.split("//")[1]
        except:
            out_name = target
            target = "http://" + target
            target_ssl = "https://" + target
        # Attempt to take a screenshot of the target using HTTP and HTTPS
        try:
            # Try HTTPS
            self.browser.get(target_ssl)
            # Attempt to dismiss any alerts
            try:
                alert = self.browser.switch_to.alert
                alert.dismiss()
            except:
                pass
            self.browser.save_screenshot(directory + out_name + "_ssl.png")
            # Try HTTP
            self.browser.get(target)
            # Attempt to dismiss any alerts
            try:
                alert = self.browser.switch_to.alert
                alert.dismiss()
            except:
                pass
            self.browser.save_screenshot(directory + out_name + ".png")
        except TimeoutException:
            pass
        except WebDriverException:
            pass
        except Exception:
            pass 
Example #24
Source File: helpers.py    From ODIN with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def setup_headless_chrome(unsafe=False):
    """Attempt to setup a Selenium webdriver using headless Chrome. If this fails, fallback to
    PhantomJS. PhantomJS is a last resort, but better than nothing for the time being.

    Parameters:
    unsafe      A flag to set Chrome's `--no-sandbox` option
    """
    try:
        chrome_driver_path = config_section_map("WebDriver")["driver_path"]
        # Try loading the driver as a test
        chrome_options = Options()
        chrome_options.add_argument("--headless")
        chrome_options.add_argument("--window-size=1920x1080")
        # Setup 'capabilities' to ignore expired/self-signed certs so a screenshot is captured
        chrome_capabilities = DesiredCapabilities.CHROME.copy()
        chrome_capabilities['acceptSslCerts'] = True
        chrome_capabilities['acceptInsecureCerts'] = True
        # For Kali users, Chrome will get angry if the root user is used and requires --no-sandbox
        if unsafe:
            chrome_options.add_argument("--no-sandbox")
        browser = webdriver.Chrome(chrome_options=chrome_options,executable_path=chrome_driver_path,
                                   desired_capabilities=chrome_capabilities)
        click.secho("[*] Headless Chrome browser test was successful!",fg="yellow")
    # Catch issues with the web driver or path
    except WebDriverException:
        click.secho("[!] There was a problem with the specified Chrome web driver in your \
keys.config! Please check it. For now ODIN will try to use PhantomJS.",fg="yellow")
        browser = setup_phantomjs()
    # Catch issues loading the value from the config file
    except Exception:
        click.secho("[*] Could not load a Chrome webdriver for Selenium, so we will try to use \
PantomJS, but PhantomJS is no longer actively developed and is less reliable.",fg="yellow")
        browser = setup_phantomjs()
    return browser 
Example #25
Source File: docker_quickstart.py    From bot with GNU General Public License v3.0 5 votes vote down vote up
def run(count=0):
    global bot
    try:
        bot = Bot(multi_logs=True, selenium_local_session=False,
                  proxy_address_port=get_proxy(os.environ.get('INSTA_USER')), disable_image_load=True)
        selenium_url = "http://%s:%d/wd/hub" % (os.environ.get('SELENIUM', 'selenium'), 4444)
        bot.set_selenium_remote_session(logger=logging.getLogger(), selenium_url=selenium_url, selenium_driver=selenium_driver(selenium_url))
        bot.login()
        bot.set_settings()
        bot.act()
    except (NewConnectionError, WebDriverException) as exc:
        bot.logger.warning("Exception in run: %s; try again: count=%s" % (exc, count))
        if count > 3:
            print("Exception in run(): %s \n %s" % (exc, traceback.format_exc()))
            report_exception(exc)
        else:
            run(count=count + 1)

    except (ProtocolError, MaxRetryError) as exc:
        bot.logger.error("Abort because of %s; \n%s" % (exc, traceback.format_exc()))
        return

    except Exception as exc:
        print("Exception in run(): %s \n %s" % (exc, traceback.format_exc()))
        report_exception(exc)
    finally:
        print("END")
        bot.end() 
Example #26
Source File: comment_util.py    From bot with GNU General Public License v3.0 5 votes vote down vote up
def is_commenting_enabled(browser, logger):
    """ Find out if commenting on the post is enabled """

    try:
        comments_disabled = browser.execute_script(
            "return window._sharedData.entry_data."
            "PostPage[0].graphql.shortcode_media.comments_disabled"
        )

    except WebDriverException:
        try:
            browser.execute_script("location.reload()")
            update_activity(browser, state=None)

            comments_disabled = browser.execute_script(
                "return window._sharedData.entry_data."
                "PostPage[0].graphql.shortcode_media.comments_disabled"
            )

        except Exception as e:
            msg = "Failed to check comments' status for verification!\n\t{}".format(
                str(e).encode("utf-8")
            )
            return False, "Failure"

    if comments_disabled is True:
        msg = "Comments are disabled for this post."
        return False, msg

    return True, "Success" 
Example #27
Source File: like_util.py    From bot with GNU General Public License v3.0 5 votes vote down vote up
def get_links(browser, page, logger, media, element):
    links = []
    try:
        # Get image links in scope from hashtag, location and other pages
        link_elems = element.find_elements_by_xpath('//a[starts-with(@href, "/p/")]')
        sleep(2)
        if link_elems:
            for link_elem in link_elems:
                try:
                    post_href = link_elem.get_attribute("href")
                    post_elem = element.find_elements_by_xpath(
                        "//a[@href='/p/" + post_href.split("/")[-2] + "/']/child::div"
                    )

                    if len(post_elem) == 1 and MEDIA_PHOTO in media:
                        # Single photo
                        links.append(post_href)

                    if len(post_elem) == 2:
                        # Carousel or Video
                        post_category = element.find_element_by_xpath(
                            "//a[@href='/p/"
                            + post_href.split("/")[-2]
                            + "/']/child::div[@class='u7YqG']/child::span"
                        ).get_attribute("aria-label")

                        if post_category in media:
                            links.append(post_href)
                except WebDriverException:
                    logger.info(
                        "Cannot detect post media type. Skip {}".format(post_href)
                    )
        else:
            logger.info("'{}' page does not contain a picture".format(page))
    except BaseException as e:
        logger.error("link_elems error {}".format(str(e)))
    return links 
Example #28
Source File: print_log_writer.py    From bot with GNU General Public License v3.0 5 votes vote down vote up
def log_following_num(browser, username, logfolder):
    """Prints and logs the current number of followers to
    a seperate file"""
    user_link = "https://www.instagram.com/{}".format(username)
    web_address_navigator(browser, user_link)

    try:
        following_num = browser.execute_script(
            "return window.__additionalData[Object.keys(window.__additionalData)[0]].data."
            "graphql.user.edge_follow.count"
        )

    except WebDriverException:
        try:
            browser.execute_script("location.reload()")
            update_activity(browser, state=None)

            sleep(10)
            following_num = browser.execute_script(
                "return window._sharedData."
                "entry_data.ProfilePage[0]."
                "graphql.user.edge_follow.count"
            )

        except WebDriverException:
            following_num = None

    with open("{}followingNum.txt".format(logfolder), "a") as numFile:
        numFile.write(
            "{:%Y-%m-%d %H:%M} {}\n".format(datetime.now(), following_num or 0)
        )

    return following_num 
Example #29
Source File: print_log_writer.py    From bot with GNU General Public License v3.0 5 votes vote down vote up
def log_follower_num(browser, username, logfolder):
    """Prints and logs the current number of followers to
    a seperate file"""
    user_link = "https://www.instagram.com/{}".format(username)
    web_address_navigator(browser, user_link)

    try:
        followed_by = browser.execute_script(
            "return window.__additionalData[Object.keys(window.__additionalData)[0]].data."
            "graphql.user.edge_followed_by.count"
        )

    except WebDriverException:  # handle the possible `entry_data` error
        try:
            browser.execute_script("location.reload()")
            update_activity(browser, state=None)

            sleep(1)
            followed_by = browser.execute_script(
                "return window._sharedData."
                "entry_data.ProfilePage[0]."
                "graphql.user.edge_followed_by.count"
            )

        except WebDriverException:
            followed_by = None

    with open("{}followerNum.txt".format(logfolder), "a") as numFile:
        numFile.write("{:%Y-%m-%d %H:%M} {}\n".format(datetime.now(), followed_by or 0))

    return followed_by 
Example #30
Source File: util.py    From bot with GNU General Public License v3.0 5 votes vote down vote up
def get_current_url(browser):
    """ Get URL of the loaded webpage """
    try:
        current_url = browser.execute_script("return window.location.href")

    except WebDriverException:
        try:
            current_url = browser.current_url

        except WebDriverException:
            current_url = None

    return current_url