Python+webdriver using profile when starting Firefox

Source: Internet
Author: User
Tags httpcontext

1. Create a Firefox profile

1.1 dos switch to Firefox's installation directory, for example: C:\Program files\mozilla Firefox

1.2 dos execute command firefor-p, pop up Create window (below:), add a profile. Built here under the C:\xxx



1.3 After creation, click on "Start Firefox", under C:\xxx can see the generation of some files (the most important seems to be cert8.db)


2. Write a test script test.py, perform the observation

The 2.1 scripts are as follows:

#coding =utf-8
Import UnitTest
From selenium import Webdriver
From selenium.webdriver.common.desired_capabilities import desiredcapabilities


Class Testfirefoxprofile (UnitTest. TestCase):
def setUp (self):
Profile = Webdriver. Firefoxprofile (R ' c:\xxx ')
Self._browser = Webdriver.remote.webdriver.WebDriver (\
Command_executor= ' Http://127.0.0.1:4444/wd/hub ', \
Browser_profile=profile,\
Desired_capabilities=desiredcapabilities.firefox)

Self._browser.get ("http://www.baidu.com")

def test_tile (self):
Assert "Baidu a bit, you'll know" in Self._browser.title

def tearDown (self):
Self._browser.quit ()


if __name__ = = "__main__":
Unittest.main ()


2.2 Starting the server---primarily to see the startup process and the use of remote methods


2.3 Execute the test.py script, the server displays the following information:

22:18:40.495 Info-java:sun Microsystems Inc. 11.0-B15
22:18:40.496 info-os:windows Vista 6.1 x86
22:18:40.507 info-v2.37.0, with Core v2.37.0. Built from revision A7C61CB
22:18:40.583 Info-default Driver Org.openqa.selenium.iphone.IPhoneDriver registration is skipped:registration Capabilities capabilities [{Platform=mac, Browsername=iphone, version=}] does not match with current Platform:vista
22:18:40.585 Info-default Driver Org.openqa.selenium.iphone.IPhoneDriver registration is skipped:registration Capabilities capabilities [{Platform=mac, Browsername=ipad, version=}] does not match with current Platform:vista
22:18:40.632 Info-remotewebdriver instances should connect To:http://127.0.0.1:4444/wd/hub
22:18:40.634 info-version jetty/5.1.x
22:18:40.634 info-started Httpcontext[/selenium-server/driver,/selenium-server/driver]
22:18:40.635 info-started Httpcontext[/selenium-server,/selenium-server]
22:18:40.635 info-started httpcontext[/,/]
22:18:40.657 info-started [email protected]
22:18:40.657 info-started HTTPCONTEXT[/WD,/WD]
22:18:40.660 info-started SocketListener on 0.0.0.0:4444
22:18:40.660 info-started [email protected]
22:18:55.135 info-executing: [New session: {Platform=any, Firefox_profile=uesdbbqaaaaiakwureyan7hfmwyaa ..., Javascriptenabled=true, Browsername=firefox, version=}] at URL:/session)
22:18:55.224 Info-creating A new session for capabilities [{firefox_profile= Uesdbbqaaaaiakwureyan7hfmwyaaaaaaqaiaaaay2vyddguzglt3wtqvfuab/bz713wfurnefb5

................................. Omitted....................

reazuq1nlgaaacwaaaakaaaaaaaaaaaaaac2guagagbzywzlynjvd3npbmcvdgvzdc1waglzac1z
Aw1wbguuy2fjagvqswecfaauaaaacackrqxgxnrtqguaaaaqaaaaiwaaaaaaaaaaaaaatogwiaia
c2fmzwjyb3dzaw5nl3rlc3qtcghpc2gtc2ltcgxllnbzzxrqswecfaauaaaacackrqxgor4zne8a
Aadoaaaajgaaaaaaaaaaaaaatoh2iaiac2fmzwjyb3dzaw5nl3rlc3qtcghpc2gtc2ltcgxllnni
C3rvcmvqswecfaauaaaacaclrqxg6sgsgmxvdqbjig0aigaaaaaaaaaaaaaatogjiqiac3rhcnr1
Cenhy2hll3n0yxj0dxbdywnozs40lmxpdhrszvblbqyaaaaajaakafsjaaa1kq8aaaa=
, Platform=any, Javascriptenabled=true, Browsername=firefox, version=}]
22:19:03.237 Info-done:/session
22:19:03.340 info-executing: [get:http://www.baidu.com] at URL:/session/2a7bc3e0-d62c-465c-8dba-2e4f962af4d7/url)
22:19:06.251 Info-done:/session/2a7bc3e0-d62c-465c-8dba-2e4f962af4d7/url
22:19:06.255 info-executing: [get title] at URL:/session/2a7bc3e0-d62c-465c-8dba-2e4f962af4d7/title)
22:19:06.299 Info-done:/session/2a7bc3e0-d62c-465c-8dba-2e4f962af4d7/title
22:19:06.328 info-executing: [Delete Session:2a7bc3e0-d62c-465c-8dba-2e4f962af4d7] at URL:/session/ 2A7BC3E0-D62C-465C-8DBA-2E4F962AF4D7)
22:19:06.528 Info-done:/session/2a7bc3e0-d62c-465c-8dba-2e4f962af4d7

Python+webdriver using profile when starting Firefox

Related Article

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.