best practices for selenium automation

Learn about best practices for selenium automation, we have the largest and most updated best practices for selenium automation information on alibabacloud.com

Selenium Python Automation note modify the link and open it based on the response property of the XPath find location

# Coding=utf-8Import timeImport UnitTestFrom Framework.browser_engine import BrowserengineFrom Pageobjects.bird_homepage Import homepageClass Baidusearch (UnitTest. TestCase):@classmethoddef setupclass (CLS): Browse = Browserengine (CLS)Cls.driver = Browse.open_browser (CLS)@classmethoddef teardownclass (CLS): Cls.driver.quit ()def test_baidu_search (self): Homepage = homepage (self.driver)Homepage.type_search (' xx ', ' xxx ')# HOMEPAGE.SEND_SUBMIT_BTN ()Self.driver.find_

Selenium+python Automation 88-sending mail when a use case does not pass

": - Wuyi Print("QQ Exchange Group: 226296743") the - Print(Is_result_pass ()) Wu -```Operation Result:```The test process has not passed the use case: Pass 2 Failure 1 Error 1False```2. Add a judgment before the last email```1 if notIs_result_pass ():2 3 #determine if the HTML report has an error4 5 6 7 #execute the Send mail function, write your own e-mail function8 9 #send_mail (sender, PSW, receiver, Smtp_server, Report_file)Ten One A -

Selenium+python Automation 89-sending mail when a use case does not pass

failure case # coding:utf-8from bs4 import BeautifulSoupimport sysreload(sys)sys.setdefaultencoding('utf8')def is_result_pass(): try: with open("result.html", "r") as fp: f = fp.read() # 读报告 soup = BeautifulSoup(f, "html.parser") status = soup.find_all(class_="attribute") result = status[2].contents[-1] # 获取报告结果 if "Failure" in result or "Error" in result: print("测试过程有不通过用例:%s"%result) return False else: r

Java+testng+maven+selenium Web Automation test Script Environment Building

write test frameworks.Since we have used testng, please at least try to use the testng function. For (String winHandle:driver.getWindowHandles ()) { Driver.switchto (). window (winhandle); } This code represents a toggle window. Interestingly, he is in the window open, first take out all the windows of the Hanles, and then one by one cut past.Because the new window must be at the end, no matter how many windows you have, this code will always find the latest

Python+selenium+eclipse performing web automation (i) Preparation

First, install EclipseSpecific can refer to http://jingyan.baidu.com/article/fea4511a130b59f7bb912503.html, step more detailedSecond, build Python+selenium environmentSpecific reference http://wenku.baidu.com/link?url=p6wc6Y2mVjZBb7_FVq41372h-MX4BrRhLccHUREWZqupI6s5Wpie7_ I0mfmtgylvvjnfofvmwta3l8p7rsesrlaag5afatr704yvlupw2dePython currently supports more than 2.7 versions of plug-ins and libraries, 3.X version and 2.7 differences, specific to individu

Easy Automation---selenium-webdriver (python) (vii)

ifrome1 (id = f1) browser.switch_to_frame ("F1 ") # Then find the ifrome2 below it (ID =f2) browser.switch_to_frame ( "f2) # Below you can manipulate elements browser.find_element_by_id (" kw" selenium ") browser.find_element _by_id ( "su" ). Click () time.sleep (3 Browser.quit () Driver.switch_to_window ()It is possible to nest not frames, but windows, and true-to-window methods: Switch_to_windowUsage is the same as Switch_to_frame:Driver.swit

"Selenium Automation-upload and download"

One, "Upload files"To locate the upload button, pass send_keys add local file path on it. Both absolute and relative paths are possible, and the key is that the uploaded file exists.#coding =utf-8From selenium import WebdriverImport Os,timeDriver = Webdriver. Firefox ()#打开上传文件页面File_path = ' file:///' + os.path.abspath (' upload_file.html ')Driver.get (File_path)#定位上传按钮, add a local fileDriver.find_element_by_name ("file"). Send_keys (' D:\\selenium_u

Easy Automation---selenium-webdriver (python) (vi)

elementFind_element_by_partial_link_text (Link_text) find_elements_by_partial_link_text (Link_text)#Find part of a link to an element of textFind_element_by_tag_name (name) find_elements_by_tag_name (name)#Find the label name of an elementFind_element_by_xpath (XPath)#Find XPath for an element Find_elements_by_xpath (XPath) # find child elements within an element Xpath Find_element_by_class_name (name) # Find the class name of an element find_elements_by_ Class_name (name) # Find the class na

Python +selenium Automation Environment Building

latest update path:Http://idea.lanyus.comSecond, install the request module, and Webdriver See Python's installation path below F:\Python\Scripts There is no Pip.exe Note: PIP is the installation management tool, if the PIP version is too low, you can use the command above to upgrade the PIP, if there is no pip you need to install PIP, or directly with the external download package installation.You can use:f:\python\scripts>easy_install.exe pip (update pip) Install

Selenium + Python deployment automation test environment

command "Easy_install pip", wait for the installation to complete 5. Install the Python-based Selenium installation package, cmd window into the Python installation directory to execute the command "Pip install Selenium", waiting for the installation to complete; 6. Download Firefox plugin, see annex 2Selenium_python_firefox.rarInput code: From selenium import w

Python+selenium webdriver Automation Test (i)

statements (file--defualt setting--------and inspections------Encoding specified for file--and Settings UTF8 ), try the above two ways, still can't solve, crash cure happened to see a post, said #coding = UTF8 This sentence must be written in the first line, after the test, sure enough success!! It seems that Python's use is poor ~ later to strengthen Python.Encoding conversion, be sure to write in the first line!!! Head Write!!! First line!! More important things to say a few times ~At this po

Element positioning of selenium automation test

Element positioning of selenium automation testFirst, selenium positioning methodThe key to automated testing is to accurately manipulate the test object, so you need to accurately locate the page elements of the system under test, there are several positioning methods:By.classnme (String className)By.cssselector (String selector)By.id (String ID)By.linktext (Str

WEB Automation test splinter and Selenium usage

There is sth wrong with input on my Ubuntu. So the first blog would is written in 中文版 about what I am doing during this weekend. I study python for a while the about Algorith and the network and now find some small project for practice. One of Pratice is to log on website automatically. Splinter is an interesting item which would cover web communication and testing. Following link is a implementation on what to log on 12306 to buy ticket presented by Youerning. http://youerning.blog.51cto.com/10

Python+selenium Automation Chapter Simulation keyboard operation

0. Import keyboard class keys () The keys () class in Selenium provides most of the keyboard manipulation methods, and the Send_keys () method is used to simulate keys on the keyboard.# 导入键盘类 Keys()from selenium.webdriver.common.keys import Keys 1. Common keyboard operation: Send_keys (keys.back_space): Delete key (BackSpace) Send_keys (Keys.space): SPACEBAR (space) Send_keys (keys.tab): Tab key (TAB) Send_keys (Keys

Python+selenium Automation -8-setting waits for three waiting methods

element_located_to_be_selected# determines whether the selected state of the element is the same as expected, passed in parameters: the positioned element, equal returns TRUE, otherwise returns falseelement_selection_state _to_be# determines whether the selected state of an element is the same as expected, passed in parameters: element positioning, equality returns TRUE, otherwise falseelement_located_selection_state_to_be# determines whether an element is still in the DOM, Passing in the Webel

Selenium+python for Web Automation testing (DEMO+API)

Selenium official websitehttp://selenium-python.readthedocs.io/Configuring the Usage environmentDownload the appropriate browser driver, Firefox is the defaultThis article is based on Chrome, placed in the scripts directoryChromedriver official: All versions of ChromedriverDocument referenceA Concise Python tutorialPython Tutorial-LiaocheOfficial document: Selenium

Original WEB UI Automation Application Testing Framework Practices-overview

A UI framework that was previously made for our department.Can not be purely interpreted as a framework, mainly to do some simple layered design to solve the stability, reduce complexity, improve maintainability and quickly build test cases and other practical problems.Main parts:1. Test data. Mainly provides the test library needs to use the data, the front-end to do data-driven.2. Testing services. The Test service class mainly provides a set of APIs for reuse purposes.3. Page encapsulation. A

Easy Automation---selenium-webdriver (python) (v)

before.Webdriverwait (DR, 10)Scans 1 page changes every 500 milliseconds in 10 seconds, ending when the specified element appears. Dr does not explain that the handle of the front operation Webdriver.firefox ()Is_displayed ()Whether the element is visible to the userClass Actionchains (Driver)Driver: Performing a user action instance webdriverGenerates the user's behavior. All actions are stored in the actionchains object. behavior that is stored through the perform (). Move_to_element (menu)Mo

The first query script for Python-based Web automation (Selenium)

Now that the Web Automation environment has been set up, it's time to start writing scripts. Let's start with a relatively simple script, as follows: #coding = Utf-8 From selenium import Webdriver Import time Try Driver = Webdriver. Chrome () # driver = Webdriver. Firefox () Driver.maximize_window () # driver.set_window_size (1200, 900) Driver.get (' https://www.baid

"Automation topic" selenium how to easily handle file uploads

When using selenium to automate, one of the headaches that we often encounter is file uploads.The difficulty of the problem is that selenium cannot recognize and manipulate the Windows window, and if we can bypass the popup box and pass the file information directly to the selection button, the difficulty is solved.the following are common page forms :parsing HTML, found that both the normal foreground and

Total Pages: 8 1 .... 4 5 6 7 8 Go to: Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.