Selenium of Python automated testing interview questions

Base

There are several kinds of waits in Selenium

  • Invisible wait/smart wait dr.implicitly_wait()
  • Explicit wait for WebDriverWait
  • Forced to wait for time.sleep()

What are the positioning methods in Selenium

8 types

  • tag
  • Three basic attributes id/name/class_name
  • link link text/partial link text
  • advanced css selectors/xpath

How to deal with the bullet box

4 bullet frames

  • div bullet box, dom bullet box, mask box directly positioned
  • alert框 dr.swich_to.alert().dismiss()
  • A new window pops up without processing / you can also switch to a new window and then close it
  • BasicAuth authorization box dr.get( http://username:password@www ..)

How does the frame page handle switching frames

How to test upload and download

  • 上传 <input type="file" style=“display: none"> send_keys()
  • download click
  • flash/ non-standard control desktop automatic script generation exe

How to test the control change of uncertain time

webdriver wait

How to take a screenshot of an element

elm.save_snapshot()

How to deal with elements that cannot be located

  • sleep
  • Observe whether the page jumps, whether the element appears, and whether the alert pops up
  • whether the element is in the frame
  • Whether the element is in the new page

How to deal with page element changes

Use PageObject

How to solve the problem of Selenium encountering flash

Use pywinauto or other GUI automation tools to generate exe and execute it with Selenium.

How to locate dynamically loaded elements on the page?

  • Trigger element loading through normal business processes, wait for a while before operating
  • Directly execute JavaScript scripts to load elements and perform operations

How to locate elements whose attributes change dynamically

Positioned using otherwise unchanged attributes.

Can Webdriver be used for interface testing?

cannot

Does Selenium support C/S mode

Selenium is a browser automation testing framework that supports B/S mode applications. C/S mode only supports some browser-based applications, and generally does not support C/S mode.

How to handle verification code

  • bypass
  • temporarily closed
  • Universal code
  • fetch from database or log
  • Send interface login bypass
  • Semi-automatic manual input
  • Image Identification
  • AI deep learning
  • spend money coding

frame package

How UI frameworks are layered

How your frame is designed

  • executive control
  • test suite
  • Example
  • Combination of business flow page objects, commonly used business processes
  • PageObject page object, page base class
  • Practical methodData readingDatabase operation logSend emailSelf-encapsulated positioning method

How the framework is selected and combined to build

  • Basic engine unittest, pytest, robot, httprunner, write by yourself
  • Data selection json/yaml, csv/excel, database, conf
  • configuration file conf/ini py xml

What should I do if I log out?

  • Increase the frequency of login
  • Before executing the use case, verify the state
  • Failed retries, plus login

Dependency handling between test cases

  • It is not recommended to have dependencies
  • Ensure order of execution
  • Run in units of use case suites during concurrency

How to deal with webdriver exception, how to restore the scene and record the result

  • Record logs, and environmental information at that time
  • Real-time screenshot and save screen recording (such as using docker+zalenium)
  • Automatically rerun after a test case fails (such as using pytest-rerunfailures)
  • Use subprocess to run, and record the subprocess exit code
  • Cache the last execution result

How to deal with garbage data

  • Test environment executes sql
  • The production environment requests the interface or executes UI steps

Practical case

Optical theory is useless, you have to learn to follow along, and you have to do it yourself, so that you can apply what you have learned to practice. At this time, you can learn from some actual combat cases.

If it is helpful to you, please like and collect it to give the author an encouragement. It is also convenient for you to quickly find it next time.

If you don’t understand, please consult the small card below. The blogger also hopes to learn and progress with like-minded testers

At the right age, choose the right position, and try to give full play to your own advantages.

My road of automated test development is inseparable from the plan of each stage along the way, because I like planning and summarizing,

Test and develop video tutorials, study notes and receive portals! ! !

Guess you like

Origin blog.csdn.net/m0_59868866/article/details/130487247