How to use test_selenium method in pytest-mozwebqa

Best Python code snippet using pytest-mozwebqa_python

settings.py

Source:settings.py Github

copy

Full Screen

1# Scrapy settings for test_selenium project2#3# For simplicity, this file contains only settings considered important or4# commonly used. You can find more settings consulting the documentation:5#6# https://docs.scrapy.org/en/latest/topics/settings.html7# https://docs.scrapy.org/en/latest/topics/downloader-middleware.html8# https://docs.scrapy.org/en/latest/topics/spider-middleware.html9from pathlib import Path10BASE_DIR = Path(__file__).resolve().parent.parent11BOT_NAME = 'test_selenium'12SPIDER_MODULES = ['test_selenium.spiders']13NEWSPIDER_MODULE = 'test_selenium.spiders'14LOG_ENABLED = True15LOG_LEVEL = 'DEBUG'16# Crawl responsibly by identifying yourself (and your website) on the user-agent17USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36'18# Obey robots.txt rules19ROBOTSTXT_OBEY = False20# Configure maximum concurrent requests performed by Scrapy (default: 16)21CONCURRENT_REQUESTS = 822# Configure a delay for requests for the same website (default: 0)23# See https://docs.scrapy.org/en/latest/topics/settings.html#download-delay24# See also autothrottle settings and docs25DOWNLOAD_DELAY = 1.526# The download delay setting will honor only one of:27#CONCURRENT_REQUESTS_PER_DOMAIN = 1628#CONCURRENT_REQUESTS_PER_IP = 1629# Disable cookies (enabled by default)30COOKIES_ENABLED = True31# Disable Telnet Console (enabled by default)32#TELNETCONSOLE_ENABLED = False33# Override the default request headers:34#DEFAULT_REQUEST_HEADERS = {35# 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',36# 'Accept-Language': 'en',37#}38# Enable or disable spider middlewares39# See https://docs.scrapy.org/en/latest/topics/spider-middleware.html40#SPIDER_MIDDLEWARES = {41# 'test_selenium.middlewares.TestSeleniumSpiderMiddleware': 543,42#}43# Enable or disable downloader middlewares44# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html45DOWNLOADER_MIDDLEWARES = {46 # 'test_selenium.middlewares.TestSeleniumDownloaderMiddleware': 543,47 'test_selenium.middlewares.SeleniumMiddleware': 800,48}49SELENIUM_DRIVER_NAME = 'chrome'50SELENIUM_DRIVER_EXECUTABLE_PATH = BASE_DIR / 'chromedriver'51SELENIUM_DRIVER_ARGUMENTS = ['start-maximized']52# Enable or disable extensions53# See https://docs.scrapy.org/en/latest/topics/extensions.html54#EXTENSIONS = {55# 'scrapy.extensions.telnet.TelnetConsole': None,56#}57# Configure item pipelines58# See https://docs.scrapy.org/en/latest/topics/item-pipeline.html59ITEM_PIPELINES = {60 'test_selenium.pipelines.TestSeleniumPipeline': 300,61}62# Enable and configure the AutoThrottle extension (disabled by default)63# See https://docs.scrapy.org/en/latest/topics/autothrottle.html64#AUTOTHROTTLE_ENABLED = True65# The initial download delay66#AUTOTHROTTLE_START_DELAY = 567# The maximum download delay to be set in case of high latencies68#AUTOTHROTTLE_MAX_DELAY = 6069# The average number of requests Scrapy should be sending in parallel to70# each remote server71#AUTOTHROTTLE_TARGET_CONCURRENCY = 1.072# Enable showing throttling stats for every response received:73#AUTOTHROTTLE_DEBUG = False74# Enable and configure HTTP caching (disabled by default)75# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings76#HTTPCACHE_ENABLED = True77#HTTPCACHE_EXPIRATION_SECS = 078#HTTPCACHE_DIR = 'httpcache'79#HTTPCACHE_IGNORE_HTTP_CODES = []...

Full Screen

Full Screen

selenium_1123.py

Source:selenium_1123.py Github

copy

Full Screen

1# -*- coding: UTF-8 -*-2#!/usr/bin/env python3# @Time : 2017/11/23 15:144# @Author : SiYe5# @PROJECT_NAME : LemonClass6# @File : selenium_1123.py7# @Software: PyCharm8#-------------------------------------------------------------------------------9from selenium import webdriver10import time11from selenium.webdriver.common.action_chains import ActionChains12class ElementLocation:13 def __init__(self):14 self.browser = webdriver.Chrome()15 self.browser.get('http://www.lemfix.com/')16 self.browser.implicitly_wait(5)17 def loginWebsite(self):18 login_element=self.browser.find_element_by_link_text("登录")19 login_element.click()20 time.sleep(1)21 self.browser.find_element_by_id("name").clear()22 self.browser.find_element_by_id("name").send_keys("zwnpepsi")23 self.browser.find_element_by_id("pass").clear()24 self.browser.find_element_by_id("pass").send_keys("zwn870706")25 self.browser.find_element_by_css_selector("input.span-primary").click()26 time.sleep(1)27 def readingArticle(self):28 self.browser.maximize_window() # 最大化窗口29 self.browser.find_element_by_xpath("//*[@id='topic_list']/div[1]/div/a").click()30 time.sleep(1)31 self.browser.back()#回退32 time.sleep(1)33 self.browser.forward()#前进34 def replyArticle(self):35 time.sleep(1)36 reply_form=self.browser.find_element_by_css_selector("div.CodeMirror-scroll") #定义回复栏位置37 ActionChains(self.browser).move_to_element(reply_form).click().perform() #点击回复栏,激活回复栏输入状态38 time.sleep(1)39 self.browser.find_element_by_xpath("//form[@id='reply_form']/div/div/div[2]/div/textarea").send_keys("这是一篇不错的文章") #在回复栏文本框内输入文字40 time.sleep(1)41 self.browser.find_element_by_xpath("//*[@id='reply_form']/div/div/div[3]/input").click()42 def closeBrowser(self):43 time.sleep(1)44 self.browser.close()#关闭当前窗口45 self.browser.quit()#关闭浏览器46test_selenium=ElementLocation()47test_selenium.loginWebsite()48test_selenium.readingArticle()49test_selenium.replyArticle()...

Full Screen

Full Screen

test_selenium.py

Source:test_selenium.py Github

copy

Full Screen

...4# 开发时间 : 2020-08-19 15:235# 文件名称 : test_selenium PY6# 开发工具 : PyCharm7from selenium import webdriver8def test_selenium():9 driver = webdriver.Chrome()10 driver.get("https://www.baidu.com/")11if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pytest-mozwebqa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful