Python – Starting Up Selenium Webdriver, with Custom User-Agent and Profile

good to know ..

Tech Kernel

I’ve been playing around with Selenium Webdriver in Python, and one of the most annoying thing I had to do again and again is looking up how to start a specific Webdriver with a custom user-agent or with a custom profile. So I decided to make this module which will take care of all the little inner workings involved while starting up a Webdriver.

The code is here –

You’ll just have to use the start_webdriver function, and it will do all the magic and return the required Webdriver.

Example usage:

import wdstart
driver = wdstart.start_webdriver(driver_name='Chrome', user_agent='Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19(KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19', profile_path='C:UsersSkullTechAppDataLocalGoogleChromeUser Data')

Although in most cases you won’t have to worry about what’s happening under the hood (they are not at all important and can be found out with a simple Google search), but still if you want you can…

View original post 26 more words


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s