Selenium: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 2: Line 2:
__TOC__
__TOC__
<br />
<br />

= Installation =


Install Selenium
Install Selenium
Line 15: Line 17:
cp geckodriver /usr/local/bin/
cp geckodriver /usr/local/bin/


= Sample Code =

<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
from selenium import webdriver
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.options import Options
import json


# When using Self Signed Certificates
profile = webdriver.FirefoxProfile()
profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
profile.accept_untrusted_certs = True
Line 26: Line 28:
options = Options()
options = Options()
options.binary_location = r"/usr/bin/firefox"
options.binary_location = r"/usr/bin/firefox"
options.add_argument("--headless")
options.add_argument("--headless") # if running on a Server with no UI


browser = webdriver.Firefox(options=options, firefox_profile=profile, executable_path="/home/ubuntu/geckodriver")
browser = webdriver.Firefox(options=options, firefox_profile=profile, executable_path="/home/ubuntu/geckodriver")
browser.get('https://testsite.com/')
browser.get('https://testsite.com/')


driver.close()
browser.close()
</syntaxhighlight>
</syntaxhighlight>