How to use selenium_major_version method in SeleniumLibrary

Best Python code snippet using SeleniumLibrary

Run SeleniumLibrary automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

event.py

Source: event.py Github

copy
1# Copyright 2008-2011 Nokia Networks
2# Copyright 2011-2016 Ryan Tomac, Ed Manlove and contributors
3# Copyright 2016-     Robot Framework Foundation
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#    http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17import abc
18from selenium.webdriver.support.event_firing_webdriver import EventFiringWebElement
19from robot.api import logger
20
21
22class Event:
23    @abc.abstractmethod
24    def trigger(self, *args, **kwargs):
25        pass
26
27
28def _unwrap_eventfiring_element(element):
29    """Workaround for Selenium 3 bug.
30
31    References:
32    https://github.com/SeleniumHQ/selenium/issues/7877
33    https://github.com/SeleniumHQ/selenium/pull/8348
34    https://github.com/SeleniumHQ/selenium/issues/7467
35    https://github.com/SeleniumHQ/selenium/issues/6604
36
37    """
38    logger.debug("Workaround for Selenium 3 bug.")
39    if not isinstance(element, EventFiringWebElement) or selenium_major_version() >= 4:
40        return element
41    return element.wrapped_element
42
43
44def selenium_major_version():
45    import selenium
46
47    selenium_version = selenium.__version__
48    (major, *sub_versions) = selenium_version.split(".")
49    return int(major)
50
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run Python Tests on LambdaTest Cloud Grid

Execute automation tests with SeleniumLibrary on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)