上一篇有說過,不同瀏覽器會有不同的Web Driver,本篇以Chrome作範例
用其他瀏覽器的請左轉別的教學喔 ><
切記Web Driver一定要和selenium和python放在同一個執行目錄底下,不然程式執行會找不到喔!
以下是有正確放在同一目錄執行的程式碼:
from selenium import webdriver #叫出同一目錄的selenium和web driver driver = webdriver.Chrome() #指定此web driver是chrome版本的 driver.get("https://www.google.com/?hl=zh_tw") #前往這個網址 driver.close() #關閉視窗
執行到第二行的時候,web driver會另外開啟一個瀏覽器視窗,視窗上會出現
「Chrome 目前受到測試軟體控制」,表示web driver已經透過程式控制瀏覽器囉!
在第三行,使用driver.get()讓web driver打開google頁面
最後一行,使用driver.close()關閉整個瀏覽器視窗,到這裡就學會自動開啟網頁的部分了!
Emphasis, aka italics, with asterisks or underscores.
Strong emphasis, aka bold, with asterisks or underscores.
Combined emphasis with asterisks and underscores.
Strikethrough uses two tildes. Scratch this.
I’m an inline-style link with title
I’m a relative reference to a repository file
You can use numbers for reference-style link definitions
Or leave it empty and use the link text itself.
URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com or http://www.example.com and sometimes example.com (but not on Github, for example).
Some text to show that the reference links can follow later.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quam nihil enim maxime corporis cumque totam aliquid nam sint inventore optio modi neque laborum officiis necessitatibus, facilis placeat pariatur! Voluptatem, sed harum pariatur adipisci voluptates voluptatum cumque, porro sint minima similique magni perferendis fuga! Optio vel ipsum excepturi tempore reiciendis id quidem? Vel in, doloribus debitis nesciunt fugit sequi magnam accusantium modi neque quis, vitae velit, pariatur harum autem a! Velit impedit atque maiores animi possimus asperiores natus repellendus excepturi sint architecto eligendi non, omnis nihil. Facilis, doloremque illum. Fugit optio laborum minus debitis natus illo perspiciatis corporis voluptatum rerum laboriosam.
Inline code
has back-ticks around
it.
var s = "JavaScript syntax highlighting";
alert(s);
s = "Python syntax highlighting"
print s
No language indicated, so no syntax highlighting.
But let's throw in a <b>tag</b>.
This is a blockquote example.
You can also use raw HTML in your Markdown, and it’ll mostly work pretty well.
Colons can be used to align columns.
Tables | Are | Cool |
---|---|---|
col 3 is | right-aligned | $1600 |
col 2 is | centered | $12 |
zebra stripes | are neat | $1 |
There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don’t need to make the raw Markdown line up prettily. You can also use inline Markdown.
Markdown | Less | Pretty |
---|---|---|
Still | renders |
nicely |
1 | 2 | 3 |