ubuntu python3.4

1. install selenium, pip install

pip install selenium

2.selenium edition 2.53.x

Tried to download it from the official website selenium3, however firefox To install a new geckodriver, I'll switch back 2.53.x 了 .

I'll add after the next study .

3. Start the sample exercise

We tested a QQ Email login program :

# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time driver = webdriver.Firefox()
driver.get("http://mail.qq.com/") if u" Sign in " in driver.title:
print("login")
driver.switch_to.frame("login_frame")
elem = driver.find_element_by_id('u')
elem.clear()
elem.send_keys( user name )
elem = driver.find_element_by_id('p')
elem.clear()
elem.send_keys( password +Keys.RETURN) driver.switch_to.default_content() assert u"QQ" in driver.title
print(u' Log in to !')
time.sleep(90)
driver.close()

At first, the user name and password find_element I can't find , It turned out to be in a iframe in , Yes switch to frame Only after that can it be smooth find_element.

 driver.switch_to.frame("login_frame")

This is also a selenium A little bit of trap Well , After that, almost everything element There's a way to find out .

4. Proxy verification

With automatic proxy ,firefox The verification window often pops up . Is very boring , And there's no way to selenium Turn off the .

So install firefox plug-in unit auto auth, solve .:)

selenium It's very convenient to use , Quick start ...

python selenium More new articles

  1. python First time in Python

    python Advantages and disadvantages : Python Many advantages , It can be summarized as follows . Simple and clear , There is only one way to do one thing . Low learning curve , Compared with many other languages ,Python Easier to use . Open source , Have a strong community and Ecology ...

  2. New to python

    New to python Be sure to learn python seek 1-100 And : i=1 s=0 while i<101: s=s+i i=i+1 print(s)

  3. 【python+selenium Study 】Python Common mistakes :IndentationError: unexpected indent

    New to python+selenium Way of learning , There will always be such and such problems .IndentationError: unexpected indent, I have stepped into this pit several times , Simply record it . We all know Python Antithetical generation ...

  4. python selenium automation ( Two ) Automated registration process

    demand : Use python selenium To automatically test a website registration process . Suppose the registration process of this website is divided into three steps , A lot of information needs to be provided : In this process , The user needs to fill in the information . Select from the drop-down menu . Select radio radio ...

  5. Python selenium Automated web crawler

    ( Happy every day ~ --- Addicts ) Go straight to the point ---Python selenium Automatically control the browser to grab the data of the web page , It contains buttons to click . Jump to the page . Search box input . The value data storage of the page .mongodb Automatically i ...

  6. Python selenium according to class Locate page elements

    In the daily web source code , We're based on elements id It's the surest thing to be positioned ,id There is no repetition in a single page . But in practice , Many front-end developers don't write for every element id attribute . Usually a period of html The code is as follows : <div cl ...

  7. New to pygame—— snake

    One . Problem utilization pygame Write the game , Do some simple games like snake eating , Keep watching and so on , Later, the code will be managed . Two . solve 1. Environment configuration python Provide a pygame Library to write the game . The first is installation pygam ...

  8. New to TensorFlow———— To configure TensorFlow

    Seeing this shows that you're right about python I already know something about it , So a lot of the basics just skip . One .TensorFlow Environment configuration : TensorFlow A lot of tutorials on the Internet are used anaconda The way , But it's easy to rush ...

  9. Use Python + Selenium Build browser crawler

    Selenium  Is a powerful browser based open source automated testing tool , By the first Jason Huggins On 2004 In ThoughtWorks launch , It provides a set of easy to use API, Simulate all kinds of browser operations ...

Random recommendation

  1. java assert

    One . Grammatical form : Java2 stay 1.4 A new keyword has been added to :assert. Use it during program development to create an assertion (assertion), its There are two grammatical forms as follows : 1.assert condition ...

  2. ASP.NET Environment FCKEditor And upload pictures and other files

    Article transferred from :http://blog.sina.com.cn/s/blog_568e66230100hy6a.html FCKEditor On 2009 It was renamed a new generation of CKEditor and CKFinder, see ...

  3. MongoDB 1: NoSQL and SQL The difference between

    Reading guide : This blog , Mainly combined with their own use in the project , Let's briefly elaborate NoSQL and SQL The difference between . that , According to their own application ,NoSQL here , The choice is MongoDB(Redis Although it is also , But it's memory storage , There is no explanation here ). ...

  4. One click cleaning Windows Rubbish BAT File code

    @echo off color 0atitle win7 One click cleaning system garbage echo ** ** ** ** ****** ** ** ** ***echo ** ** ** ** ****** ** * ...

  5. MUI Practical tutorial

    MUI practical JS course : https://www.kancloud.cn/benhailong/mui/319751  MUI Practical tutorial : https://www.kancloud.cn/benhail ...

  6. slick Plug in some configuration

  7. Performance testing day02_ Preview knowledge

    Before entering the next day of study , I think we need to know the basic knowledge in advance , So this article is mainly about the preview course , The explanation about protocol and packet capture ( Principles and tools ). It can be said that server based performance is generally protocol based , So we need to understand the agreement , With ...

  8. sublime plug-in unit CSS turn rem To configure

    { "px_to_rem": 40, //px turn rem Unit ratio of , The default is 40 "max_rem_fraction_length": 6, //px turn rem Decimals of ...

  9. solve : Edit a MMS , Attachment select add audio , Return to the editing interface and select play, Can't play , No sound

    [ Operation steps ]: Edit a MMS , Attachment select add audio ( External audio ), Return to the editing interface and select play, The menu key selects view slideshow [ test result ]: Can't play , No sound [ Expected results ]: It can play Based on past experience ( ...

  10. .net Set under

    The operation of set is very common in coding . But because several sets are often used . And ignore some of the less commonly used sets . I'll sort it out here . First, let's look at the interface : 1.IEnumerable, Returns an enumerator that iterates through the collection . 2.IEnumera ...