about where to go Web UI Automation test script (Python implementation)

Source: Internet
Author: User

UI Automation Testing
Qunar Ticket Search Scenario
Visit Qunar Ticket Home http://flight.qunar.com, select "One Way", enter the departure, arrival city, select the date of today+7, click "Search", jump to the ticket one-way Search list page.
Stay on the list page for 1 minutes, and the search end appears on the page.
In the event of a flight list, the "Ticket" button is randomly selected for the "Every flight is subject to tax", "first Pass", "second Journey" will appear in the expanded list, and a "ticket" button will appear at the bottom of the expanded list for the line that does not appear "tax-charged per flight".
If the list of flights does not appear, the page will appear "No flights currently available for this route"
Use MAVEN to create a Java project, introduce the selenium framework, write WebUI code, and implement the manual and validation described above. Requires the ability to randomly verify any search conditions within 3 months of the 100 city pairs.

See the ethanol blog mentioned, deliberately find someone else's article looked under, but Java, not how to read.

The following is the first step: select "one-way", enter the departure, arrival city, select Departure + 7th after the date (the original is today+7 date), click "Search", jump to the ticket one-way Search list page, the rest of the later.

Two difficulty, one get departure and add 7 days, one is return date. The first one with the Python datetime module, the second has two methods: 1, in the back of the input box there is a "back" prompt text, click, you can enter, this is a bit simple. 2, another way is to use JS, below is the latter method:

#Coding=utf-8 fromSeleniumImportWebdriverImporttime,datetimefromcity= u'Guangzhou'tocity= u'Shanghai'Driver=Webdriver. Firefox () Driver.get ('http://flight.qunar.com/') Driver.find_element_by_name ('fromcity'). Clear () Driver.find_element_by_name ('fromcity'). Send_keys (fromcity) driver.find_element_by_name ('tocity'). Clear () Driver.find_element_by_name ('tocity'). Send_keys (tocity) El= driver.find_element_by_id ('FromDate'). Get_attribute ('value') ToDate= Str (Datetime.datetime.strptime (EL,'%y-%m-%d'). Date () +datetime.timedelta (days=7)) Driver.execute_script ('$ ("#dfsForm. js_arrivaldatediv_disable"). CSS ("display", "none")') Driver.execute_script ('$ ("#dfsForm. Js_arrivaldatediv"). Removeattr ("style")') driver.find_element_by_id ('toDate'). Clear () driver.find_element_by_id ('toDate'). Send_keys (todate) driver.find_element_by_class_name ('Btn_search'). Click () time.sleep (5) Driver.quit ()

about where to go Web UI Automation test script (Python implementation)

Related Article

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.