目录
1. what is selenium:
2. components of selenium
3. selenium WebDriver
4. element
5. locate element
6. beautiful soup
a set of tools and libraries that automate web browser actions
通过web-driver packages to control browser and emulate user oriented actions
4 components of selenium
1) selenium IDE: record and playback; used for prototype testing
2) selenium RC(remote control): a test tool that allows you to write automated web app ui test
3) selenium WebDriver
4) selenium Grid: used for parallel or distributive testing
WebDriver API: drive the browser natively, as a user would either locally or on a remote machine using the selenium server
when executing a test script using WebDriver:
-> executer one selenium command
-> generate http request and send to browser driver
-> driver receive http request through the http server
-> the server decides all the steps to perform instructions which are executed on the browser
-> execution status is sent back to the http server which is subsequently sent back to the automation script
elements: everything you see on a page is an element(field, link, text, image...)
dynamic elements: ID, name, class or css-attributes are not fixed, will change whoever page is reloaded
pip install beautifulsoup4
page_source_overview = driver.get_source
from bs4 import BeautifulSoup
soup = BeautifulSoup(page_source_overview, 'lxml')
title_finder = soup.find_all('span', class_='title')
for title in title_finder:
print(title.string)