Package: easy-py-selenium
A list of functionalities that makes working with Selenium much easier.RequirementsChrome or FirefoxPython 3.7+Installationpip install easy-py-seleniumTOCCreate Undetectable Chrome DriverFeatures:Passed the antibot testUsageOptionsRemote browser (debugging mode)FeaturesUsageOptionsCreate Firefox Driver (Geckodriver)Features:UsageOptionsEasy authenticationCookiesUtility functionsMimic real user inputDriver safe quitSend emailsScrollinguserAgentScreenshotsLoggingTestingInstallationDownlaod the projectEnvironment variablesCreate Undetectable Chrome Drivereasy-selenium will download and patch a Chrome driver to make it undetectable. So that you can use an undetectable Chrome driver for your Python Selenium code.Features:Download the exact chrome driver based on your OS and installed chrome version.Remove browser control flagRemove signature in javascriptSet User-AgentUse maximum resolutionRun Chrome driver on headless mode.Unmute the sounds of the browser.Passed the antibot testUsagefrom easy_selenium.driver.chrome.driver import Driver
driver = Driver()
chrome = driver.create()
# Change useragent
driver.useragent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
chrome.get("https://selmi.tech")OptionsLoad ProfileLaunch Chrome with its default or custom profile so that you can use cookies and site preferences from that profile.chrome = driver.create_driver(profile="")Note: Make sure to provide the absolute path of your profile and if the given profile folder doesn't exist, it'll be created.To find path to your chrome profile data you need to type chrome://version/ into address bar .HeadlessWe can use a headless chrome browser to lower memory overhead and faster execution for the scripts that we write.chrome = driver.create_driver(headless=False)Remote browser (debugging mode)It launches a new Chrome session from a new Terminal (cmd) window on a given port number and profile path. It allows you to control an existing Chrome session.FeaturesOpen Chrome Instance on debugging modeControl an existing Chrome instance.Save/ load Chrome profiles.Usagefrom easy_selenium.driver.chrome.driver import Remote
remote = Remote()
chrome = remote.create()

chrome.get("https://selmi.tech")OptionsControl an existing Chrome sessionMake sure that the session is up and running.
Remined:Windows:chrome.exe --remote-debugging-port=9000Linux/ Mac:/usr/bin/google-chrome --remote-debugging-port=9000from easy_selenium.driver.chrome.driver import Remote
remote = Remote()
chrome = remote.create(control_existing_instance=True, debug_port=9000)Launch a new Chrome session and save cookies in a folder (profile)To use a custom profile, put the its path in profile_path, and make sure to use the absolute path.from easy_selenium.driver.chrome.driver import Remote
remote = Remote()
chrome = remote.create(profile="C:\path")Create Firefox Driver (Geckodriver)easy-selenium will download and launch Geckodriver. But it will be detected as bot.Features:Download the exact the latest geckodriver.Set User-AgentUse maximum resolutionRun geckodriver on headless mode.Unmute the sounds of the browser.Usagefrom easy_selenium.driver.firefox.driver import Driver
driver = Driver(binary_path)
firefox = driver.create()

firefox.get("https://selmi.tech")OptionsLoad ProfileLaunch Firefox with its default or custom profile so that you can use cookies and site preferences from that profile.firefox = driver.create_driver(profile="")Note: Make sure to provide the absolute path of your profile.For Windows users, you can find your profile path by pressing the Windows Key key and then start typing: %APPDATA%\Mozilla\Firefox\Profiles\HeadlessWe can use a headless Firefox browser to lower memory overhead and faster execution for the scripts that we write.firefox = driver.create_driver(headless=False)Easy authenticationAutomate the login process to a list of websites. Including:Linkedinfrom easy_selenium.driver.chrome.driver import Driver
from easy_selenium.authentication.login.linkedin import Login
driver = Driver()
chrome = driver.create()
login = Login("example@gmail.com", "password")
login.start(chrome)Googlefrom easy_selenium.driver.chrome.driver import Remote
from easy_selenium.authentication.login.google import Login
driver = Remote()
chrome = driver.create()
login = Login("example@gmail.com", "password")
login.start(chrome)CookiesGet and set cookies with the Selenium methods get_cookies() and add_cookie()ExampleSave cookiesfrom easy_selenium.cookies.cookies import Cookies
cookies = Cookies()
cookies.save(driver, url, cookies_file_name, cookies_folder_path=None)Load cookiesfrom easy_selenium.cookies.cookies import Cookies
cookies = Cookies()
cookies.load(driver, url, cookies_file_name, cookies_folder_path=None)Utility functionsA list of functions that you might need when you use Selenium.Mimic real user inputWrite texts in fields like a real human, send keys one by one.from easy_selenium.common.funcs import send_keys_one_by_one
send_keys_one_by_one(controller, keys, min_delay=0.05, max_delay=0.25)Driver safe quitWhen using headless browser, it's important to make sure that there are no unnecessary driver left running.
Set exit to False to avoid sys.exit() once the function is fired.from easy_selenium.common.funcs import driver_safe_quit
driver_safe_quit(driver, exit=True)Send emailsMany times I had to copy the same function in many Selenium projects.from easy_selenium.common.funcs import send_email
send_email(message, sender, password, receiver)ScrollingKeep scrolling until the end of the pagefrom easy_selenium.common.funcs import scroll_until_the_end
scroll_until_the_end(driver)Scroll to an elementfrom easy_selenium.common.funcs import scroll_to
scroll_to(driver, element)Scroll from x position to y positionfrom easy_selenium.common.funcs import scroll_from_to
scroll_from_to(driver, x, y)userAgentfrom easy_selenium.common.funcs import get_user_agent
get_user_agent(driver)ScreenshotsPage Screenshotfrom easy_selenium.common.funcs import page_screenshot
page_screenshot(driver, file_name)Element Screenshotfrom easy_selenium.common.funcs import element_screenshot
element_screenshot(driver, file_name)LoggingTo make logging simple, I'm usingLoguru.Keep logging the same way:from easy_selenium.logger import loggerTestingI'm usingPytest.
pytest requires: Python 3.7+ or PyPy3.Installationpip install -U pytestDownlaod the projectgit clone https://github.com/SelmiAbderrahim/easy-selenium
cd easy-seleniumEnvironment variablesTo do all the testing, create a '.env' file in your working directory with these values:LINKEDIN_EMAIL_ADDRESS=emial@example.com
LINKEDIN_PASSWORD=passwordOtherwise uncomment the functions you want to exclude.Run testspytest easy_selenium/tests/Was ituseful?then ⭐it.Thanks.