Use of selenium tools for automated testing

1. The premise of automated testing

1.1 What is automation?

  • Reduce labor costs
  • Do a lot of repetitive work
  • Improve test efficiency
  • Ensure consistency of work and increase trust
  • Complete work that cannot be done by hand

1.2 Is it suitable for automation?

  • Time (long project cycle)
  • People (familiar with automation)
  • System (the main body of the project is stable)
  • Leadership (leadership supports recommended use of automation)

1.3 Under what circumstances do automation

  • unit test?
  • Integration Testing?
  • interface test?
  • UI testing

1.4 What kind of projects need to be automated

  • Demand changes slowly
  • long cycle
  • Scripts can be reused

1.5 Selection of automation tools and frameworks

  • Selenium Webdriver
  • FireBug
  • FirePath

2. Introduction to Selenium

2.1 History of Selenium

  • A colleague Jason Huggins developed through the js code base to reduce testing work

2.2 Selenium family members

  • Selenium RC
  • Selenium IDE (automated script recording tool)
  • Selenium Webdriver
  • Selenium Grid (running scripts in different browsers, etc.)

2.3 How Selenium works

 ↓ ———————— Response ————————    
脚本 ====> webdirver ===> 浏览器
 —————————— Request —————————↑

3. Essential tools for automated testing

  • Select the Firefox browser, and the version generally chooses between version 27-32
  • Install FireBug, FirePath

Installation and use of Selenium IDE

  • Install

  • to record
打开--浏览器顶部-工具-selenium IDE-打开
录制按钮-红色的时候是录用状态
URL
Test Case
操作区域:command操作-target元素-value值

4. Introduction to Selenium IDE installation and use

5. Automated framework environment construction

6. Common browser startup

  • firefox start
driver = new FirefoxDriver()
System.setProperty("webdriver.firefox.bin", "E:/Firefox/firefox.exe")
  • Chrome starts
driver = new ChromeDriver();
System.setProperty("webdriver.chrome.driver", "E:/webdriver/chromedriver/chromedriver.exe")
  • IE starts
    • Need to download the driver
  • driver = new InterExplorerDriver();
    System.setProperty("webdriver.ie.driver", "E:/webdriver/iedriverserver/IEDriverServer.exe")
    

Webdriver common element positioning

  1. By.id
  2. By.name
  3. By.tagName
  4. By.tagName
  5. By.className
  6. By.linkText
  7. By.partialLinkText
  8. By.xpath
  9. By.css
  10. table

Common API modules:

  1. Open URL API.

    • Driver.get()
    • Driver.navigate.to()
  2. Manipulating the browser API

    • Driver.navigate().refresh Refresh
    • Driver.navigate().forward
    • Driver.navigate().back backwards
    • Driver.getTitle() prints the title
    • Driver.getCurrentUrl() Get the current URL address
    • Driver.manage().window().maximize()Browser size - - - - - Driver.quit Exit and close the browser without closing the process
    • Driver.close() closes the browser, closes the process, operates the scroll bar through Js, operates the browser cookie) 
  3. Input box operation API

    • Send Keys()
    • Clear()
    • getText()
    • Click()
  4. Select Box Handling

    • Single box
    • check box
    • drop down box
    • iframe window handling
    • Pop-up processing
  5. Handling of page elements

    • waiting to load
    • Obtain the css attribute of the object by obtaining the element value according to the attribute
    • Obtain object status: whether the page displays isdisplay
    • Whether the element exists find_element
    • Whether the element is selected isSelected()
    • Whether it is in grayed state idEnabled
    • Special operation explanation:
      • The error is saved as a screenshot
      • Simulate right mouse button
      • mouseover
      • upload files
      • Date Control Handling
      • Browser scroll bar operation
        6, window processing API 7, JS processing 8, special processing

The following are supporting learning materials. For friends who do [software testing], it should be the most comprehensive and complete preparation warehouse. This warehouse also accompanied me through the most difficult journey. I hope it can help you too!

Software testing interview applet

The software test question bank maxed out by millions of people! ! ! Who is who knows! ! ! The most comprehensive quiz mini program on the whole network, you can use your mobile phone to do the quizzes, on the subway or on the bus, roll it up!

The following interview question sections are covered:

1. Basic theory of software testing, 2. web, app, interface function testing, 3. network, 4. database, 5. linux

6. web, app, interface automation, 7. performance testing, 8. programming basics, 9. hr interview questions, 10. open test questions, 11. security testing, 12. computer basics

Information acquisition method:

Guess you like

Origin blog.csdn.net/myh919/article/details/132104217