Enhance your Selenium experience with streamlined functionality!
*Update Version 1.1.3: In the new version 1.1.3, We have fixed a few small errors that appeared in the old version. Now you can "Get url, Right Click, Double Click and Click a specific element among many similar elements!
Download and install to experience the new version now!
Download on nuget: https://www.nuget.org/packages/Selenium.SeleniumHelper
Get the Url:
- get URL
SeleniumHelper.GetUrl(driver);
- Right Click
SeleniumHelper.RightClick(driver, "css", "abcxyz (Element)");
- Double Click
SeleniumHelper.DoubleClick(driver, "css", "abcxyz (Element)");
- Click a specific element among many similar elements
Example: I have an element value I want to click, but on that website there are many similar elements. I want to click that element specifically, for example, that element has a search number of 9. I will set the ElementSpecified = 9 assignment variable. SeleniumHelper.clickWithElementSpecified(driver, "css", "abcxyz (Element)", 9);
*Update Version 1.1.0: In the new version 1.1.0, We have fixed a few small errors that appeared in the old version. Now you can add preferences and use the new undetect Chrome browser!
Download and install to experience the new version now!
Download on nuget: https://www.nuget.org/packages/Selenium.SeleniumHelper
From now everybody can add the Preference:
Add Preference guide:
- add Preference
var prefs = new Dictionary<string, object>() { {"credentials_enable_service", false }, {"password_manager_enabled", false} }; seleniumHelper.Prefs = prefs;
Use UndetectedChromeDriver Guide.
- UndetectedChromeDriver
var seleniumHelper = new SeleniumHelper(); var driver = SeleniumHelper.OpenUndetectChrome(seleniumHelper); //but you need to install UndetectedChromeDriver from https://github.com/fysh711426/UndetectedChromeDriver along with SeleniumHelper to avoid errors due to different versions.
*Update Version 1.0.7 In the new version 1.0.7, you can now Screenshot the Chrome to Base64, Add BrowserPath, driverPath and Get value from ExcuteJS!
Download and install to experience the new version now!
Download on nuget: https://www.nuget.org/packages/Selenium.SeleniumHelper
From now on when you take a selenium screenshot, it will return the result in base64 format making your image capture more convenient:
-
For an driver screenshot, set type to "driver".
-
For an element screenshot, set type to "element".
Screenshot Selenium Guide.
-
Driver screenshot
IWebDriver driver = null; SeleniumHelper.TakeScreenShotToBase64(driver, "driver");
-
Element screenshot
IWebDriver driver = null; var element = iwebdriver.FindElement(By.XPath("abcxyz")); SeleniumHelper.TakeScreenShotToBase64(driver, "element", element);
Add BrowserPath & DriverPath Selenium Guide.
- BrowserPath
seleniumHelper.UseBrowserPath = true; seleniumHelper.BrowserPath = "abcxyz";
- DriverPath
seleniumHelper.UseDriverPath = true; seleniumHelper.DriverPath = "abcxyz";
ExcuteJS.
- Get value from ExcuteJS
var height = SeleniumHelper.ExcuteJS(driver, "return Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);");
- Use ExcuteJS
SeleniumHelper.ExcuteJS(driver, "return Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);");
Version 1.0.3: In the new version 1.0.3, you can now add a Proxy containing authentication directly to Chrome!
Download and install to experience the new version now!
Download on nuget: https://www.nuget.org/packages/Selenium.SeleniumHelper
To configure a proxy in your settings, use the following guidelines:
-
For an HTTP proxy, set TypeProxy to 0.
-
For a SOCKS5 proxy, set TypeProxy to 1.
The proxy configuration should be specified in one of these formats:
-
ip:port for simple IP address and port configuration.
-
ip:port:user:pass if authentication with a username and password is required.
Make sure to choose the correct format based on your proxy type and whether authentication is needed.
- Proxy have ip:port
seleniumHelper.TypeProxy = 0; seleniumHelper.Proxyaddress = "a:b";
- Proxy have ip:port:user:pass
seleniumHelper.TypeProxy = 0; seleniumHelper.Proxyaddress = "a:b:c:d";
SeleniumSupport is a robust library created to simplify and enhance your Selenium-based automation tasks. It introduces user-friendly methods and configurations to streamline browser manipulation and interaction. Key features include disabling images for speed, using browser extensions, managing multiple profiles, and proxy configurations. With SeleniumSupport, developers can automate more efficiently, reducing the boilerplate code typically associated with Selenium.
- Ensure you have Selenium WebDriver installed.
- Compatible with major operating systems (e.g., Windows, macOS, Linux).
- Download the library from the provided repository link.
- Include the library in your project directory.
- Download on nuget https://www.nuget.org/packages/Selenium.SeleniumHelper
Execute your Selenium scripts with enhanced capabilities:
- Usage:
-
var helper = new SeleniumHelper(); var driver = SeleniumHelper.OpenBrowser(helper); // Your automation code here
OpenBrowser(SeleniumHelper seleniumHelper)
-
Purpose: Initializes and returns a
ChromeDriver
instance configured with options specified in theSeleniumHelper
instance. -
Usage:
ChromeDriver driver = null; SeleniumHelper seleniumHelper = new SeleniumHelper(); seleniumHelper.DisableImages = false; seleniumHelper.UseExtension = false; seleniumHelper.UseAppMode = false; seleniumHelper.ExtensionPath = ""; seleniumHelper.UseDebugPort = false; seleniumHelper.DebugPort = ""; seleniumHelper.UseProfile = true; seleniumHelper.ProfilePath = uidProfile; seleniumHelper.ProxyType = 0; seleniumHelper.ProxyAddress = ""; driver = SeleniumHelper.OpenChrome(seleniumHelper);
WaitElement(IWebDriver driver, string type, string element, int repeat, int timeDelay)
-
Purpose: Waits for an element to become available on the web page, retrying a specified number of times.
-
Usage:
bool isElementFound = SeleniumHelper.WaitElement(driver, "id", "submit-button", 5, 1);
CheckPageSource(IWebDriver driver, int timeWait, string text)
-
Purpose: Checks if a specific text is present in the page source within a specified time period.
-
Usage:
bool isTextFound = SeleniumHelper.CheckPageSource(driver, 3, "Welcome");
ExcuteJS(IWebDriver driver, string command)
-
Purpose: Executes JavaScript on the current page.
-
Usage:
SeleniumHelper.ExcuteJS(driver, "alert('Hello World');");
OpenNewTab(IWebDriver driver)
:
-
Opens a new browser tab.
-
Example:
SeleniumHelper.OpenNewTab(driver);
SwitchtoFirstTab(IWebDriver driver)
,SwitchtoLastTab(IWebDriver driver)
,SwitchtoCloseFirstTab(IWebDriver driver)
,SwitchtoCloseLastTab(IWebDriver driver)
:
-
Manage browser tabs by switching to or closing the first or last tab.
-
Example:
SeleniumHelper.SwitchtoFirstTab(driver); SeleniumHelper.CloseDriver(driver);
AddCookieIntoChrome(IWebDriver driver, string cookie, string domain)
:
-
Adds a cookie into Chrome.
-
Example:
SeleniumHelper.AddCookieIntoChrome(driver, "sessionId=abc123", "example");
GetCookieFromChrome(IWebDriver driver)
:
-
Retrieves cookies from Chrome.
-
Example:
string cookies = SeleniumHelper.GetCookieFromChrome(driver);
- BUI QUANG VINH
- Contact: BUI QUANG VINH
- 1.0.3
This project is licensed under the MIT License - see the LICENSE.md file for details.
Support the ongoing development and improvement of SeleniumSupport: