In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how selenium3 webdriver launches Firefox, chrome, edge and Safari browsers, which has certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
Starting common Firefox and chrome in selenium2 is actually relatively easy, and there are a lot of tutorials on the Internet. Now the latest version of selenium is 3.x, which is not much different from selenium2, except that it simplifies some things that are not used, and then the support for the browser is better, for example, the high version of firefox, chrome, edge and so on can be perfectly supported, so that we do not have to be limited by the version.
But many children's shoes will encounter all kinds of problems when starting the browser with selenium3. Although there are many solutions on the Internet, there is no summary, and the solution is too complicated, so this time I will summarize the methods of launching common browsers using selenium3 in python.
Premise
Install python3 and configure environment variables
Selenium3 webdriver launches Firefox browser
1. Select the corresponding Mozilla GeckoDriver download, address: https://github.com/mozilla/geckodriver/releases
2. Put the exe file in the archive into the root directory of python
3. To install the latest version of Firefox, it must be higher than 48.
4. Run the code to start
From selenium import webdriver # method 1: directly launch the browser driver = webdriver.Firefox ()''way 2: the advantage of starting the browser by specifying profile is that the browser is launched with our configured settings to view the file path of profile as follows: Firefox menu > help > troubleshooting information > display folder' # define profile file path profile_ff = "the full path of your actual profile file Note that the escape character "# specifies that the specified profile driver = webdriver.Firefox (fp) is loaded when the browser is launched with this profile fp = webdriver.FirefoxProfile (profile_ff) #
Tip: if you do not want Firefox to upgrade automatically, you can make the following changes: enter pref under defaults under Firefox installation directory, modify channel-prefs.js, and eventually change the content to: pref ("app.update.channel", "default")
Selenium3 webdriver launches chrome browser
1. Select the corresponding Google Chrome Driver download, address: https://sites.google.com/a/chromium.org/chromedriver/downloads
2. Put the exe file in the archive into the root directory of python
3. Install the latest version of chrome
4. Run the code to start
From selenium import webdriver # method 1: directly launch the browser driver=webdriver.Chrome () # profile of 2:chrome, and enter chrome://version/, in the browser to view your "profile path" profile_chrome ='--user-data-dir= your own chrome profile full path 'option=webdriver.ChromeOptions () option.add_argument (profile_chrome) driver=webdriver.Chrome (chrome_options=option)
Selenium3 webdriver launches edge browser
1. Check the version number of edge (html) on your computer first.
2. Then download the corresponding version of Microsoft Edge Driver at https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
3. Put exe in the root directory of python
4. Write code and run
From selenium import webdriver driver = webdriver.Edge ()
Selenium3 webdriver launches Safari browser
Simple enough to doubt life, just write the code and run it
From selenium import webdriver driver = webdriver.Safari () Thank you for reading this article carefully. I hope the article "how selenium3 webdriver launches Firefox, chrome, edge and Safari browsers" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.