Webdriver Advanced App-launches the Firefox browser window with User configuration information

Source: Internet
Author: User
Tags blank page

Because the new Firefox browser window is enabled when Webdriver launches Firefox browser, the information that is already configured on the current machine's Firefox browser is not valid in the test, such as the browser plugin, personal favorites, etc. that have been installed. In order to resolve this issue, the automation test script needs to use the specified configuration information to launch the Firefox browser window.

1. Generate a user-defined Firefox browser profile:

Use the CD command in CMD to enter the directory where the Firefox.exe file is located (for example: C:\Program Files\Mozilla Firefox),
and enter the Firefox.exe-profilemanager-no-remote command, and then press ENTER,
Bring up the "firefox– Select User Profile" Action window


If Firefox.exe-profilemanager-no-remote executes a popup page saying that the path cannot be found, the workaround:
In the Firefox menu "Help", select "Troubleshooting Information", click on the page in the pop-up to find the "Configuration folder"
option, click "Open Folder" to get the full path of the default configuration file.

The 2.python implementation code is as follows:

#Encoding=utf-8 fromSeleniumImportWebdriver fromSelenium.common.exceptionsImportnosuchelementexceptionImportUnitTest, timeclassTestfailcapturescreen (unittest. TestCase):defsetUp (self):#to create a path variable that stores a custom configuration file        #Propath = "C:\\users\\wuxiaohua\\appdata\\roaming\\mozilla\\firefox\\profiles\\tbbmxtkv.webdriver"        #Propath = "C:\\users\\wuxiaohua\\appdata\\roaming\\mozilla\\firefox\\profiles\\g6m1cswj.default"Propath ="C:\Users\Administrator\AppData\Roaming\Mozilla\Firefox\Profiles\ffv3vcdx.default"        #Propath = "C:\\USERS\ADMINISTRATOR\APPDATA\ROAMING\MOZILLA\FIREFOX\PROFILES\W6K7FIWP.QWQ1"        #load the custom configuration file into the Firefoxprofile instance,        #equivalent profile = Webdriver. Firefoxprofile (Propath)Profile =Webdriver.firefox.firefox_profile. Firefoxprofile (Propath)#add a new profile to the Firefox browser homepage set to Sogou homepageProfile.set_preference ("Browser.startup.homepage","http://www.sogou.com")        #The Set Start page is not a blank page, 0 indicates a blank page,        #This step must be done, otherwise the homepage set will not take effectProfile.set_preference ("Browser.startup.page", 1)        #launch a Firefox browser with custom profilesSelf.driver = Webdriver. Firefox (executable_path="E:\\geckodriver", firefox_profile=Profile )defTestsogousearch (self):#wait 5 seconds for the browser to start to completeTime.sleep (5)        Try:            #Find Sogou Home Search Input Box page elementSearchBox = self.driver.find_element_by_id ("Query")            #Enter "Glory Road automation Test" in the Found search input boxSearchbox.send_keys (U"the road to glory automated testing")            #Find the Search button and clickSELF.DRIVER.FIND_ELEMENT_BY_ID ("STB"). Click () time.sleep (10)        exceptnosuchelementexception, E:Print "Modifying the browser home page with a custom profile is unsuccessful! "    defTearDown (self):#Exit IE Browserself.driver.quit ()if __name__=='__main__': Unittest.main ()

Webdriver Advanced App-launches the Firefox browser window with User configuration information

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.