Answer the question
In order to leave comments, you need to log in
Chrome headless and python, where to start?
Hello readers.
Briefly about myself and what I do - I have been working as a QA for more than 1 year, and have not previously encountered programming. In my career, the very moment has come when it's time to evolve into QA automation. After spending a lot of time collecting information, I came to the conclusion that the most suitable language for automators is python. Also, I often met information that selenium webdriver is no longer a cake and is inferior in capabilities to headless browsers, especially after the release of chrome headless.
Now to the point. I spent a week searching for information, but I did not find a single tutorial for dummies - what and in what order to install, where to start, how to write tests in Python for chrome headless. Who can share experience, or materials for training? Where to start?
Answer the question
In order to leave comments, you need to log in
Python 2.7
• PyCharm
• Selenium WebDriver
is what you should have to start with
Then read
https://selenium-python.readthedocs.io/
www.techbeamers.com/python-tutorial-step-by-step
www.techbeamers.com/selenium -webdriver-tutorial
Write the first test for Facebook login for example
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.support.ui import Select
import os
import datetime
import sys
import pytest
base_url = ("https://facebook.com")
driver = webdriver.Chrome(".\chromedriver")
дальше навигация по странице
driver.get(base_url)
driver.maximize_window()
username = driver.find_element_by_id("Username")
password = driver.find_element_by_id("Password")
username.send_keys("username")
password.send_keys("pass")
driver.save_screenshot(".\Path to folder\landing_page.png")
driver.find_element_by_link_text('Logout').click()
driver.quit()
It's probably better to use selenium after all, because. will be able to test different browsers, not just chrome.
I have not tried it, but they write that selenium can be used with headless chromium, here is an example
https://medium.com/@pyzzled/running-headless-chrom...
In fact, we just add one line to the standard selenium code.
Thank you figured it out) I use selenium web. driver, and when running tests, I specify that I use the headless version of the browser.
Registered at the beginning:
options = webdriver.ChromeOptions()
options.add_argument('headless')
And when Appealing:
driver = webdriver.Chrome(chrome_options=options)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question