当前位置:网站首页>Selenium interview question sharing

Selenium interview question sharing

2022-06-12 09:13:00 Software testing Lao Mo

Catalog

1、selenium How to determine the existence of an element in ?

2、selenium in hidden Or is it display = none Whether the element of can be positioned to ?

3、selenium How to ensure the success rate of operation elements ? That is to say, how to ensure that the elements I click on must be clickable ?

4、 Is it necessary to connect to the database for data verification when testing automatically ?

5、id,name,clas,xpath, css selector These attributes , Which one do you prefer the most , Why? ?

6、 How to locate dynamically loaded elements on a page ?

7、 How to locate elements with dynamic attributes ?

8、selenium What is the principle of ?

9、webdriver What is your agreement ?

10、 Which is used when starting the browser webdriver agreement ?

11、 What is? page object Design patterns ?


1、selenium How to determine the existence of an element in ?

selenium There is no native method to determine whether an element exists in , In general, we can locate elements + Judge the way of exception capture .

# Determine whether an element exists

try:dr.find_element_by_id('none')except NoSuchElementException:print 'element does not exist'

2、selenium in hidden Or is it display = none Whether the element of can be positioned to ?

Can not be ,selenium Cannot locate invisible elements .display=none The element of is actually invisible .

                         

3、selenium How to ensure the success rate of operation elements ? That is to say, how to ensure that the elements I click on must be clickable ?

  • When the network speed is not good , Use the appropriate waiting time
  • The clicked element must occupy a certain space , because selenium By default, it will go to the center point of this element , Elements that don't take up space can't calculate the center point ;
  • The clicked element cannot be obscured by other elements ;
  • The clicked element cannot be in the viewport outside , That is, if the element must be visible or made visible by scroll bar operation ;
  • Determine whether an element can be clicked

How to improve selenium The speed of script execution ?

  • Use a higher configured computer and choose a faster network environment
  • Use more efficient languages , such as java The execution speed is faster than python
  • Optimize the code
  • Don't blindly add sleep, Try to use explicit wait
  • about firefox, Consider using test specific profile, Because every time you start the browser firefox Will create 1 A new one profile, For this new profile, All static resources are downloaded directly from the server , Instead of loading from the cache , This leads to the problem that the running speed of use cases is particularly slow when the network is bad
  • chrome The browser and safari The execution speed of the browser seems to be the fastest
  • Consider distributed execution or using selenium grid

Use cases are often unstable in the running process , That is to say, this time we can pass , I can't pass next time , How to improve the stability of use cases ?

  • Test exclusive profile, Try to cache static resources
  • Try to use explicit wait
  • Try to use a test specific environment , Avoid other types of testing at the same time , Interfere with data

What is the execution strategy for your automation use cases ?

  • Execute... Daily : For example, execute on the trunk every night
  • Cycle execution : every other 2 Execute every 1 / 2 of the development hours
  • Dynamic execution : Execute every time code is submitted

4、 Is it necessary to connect to the database for data verification when testing automatically ?

In general, you don't need , Because this is what the unit test layer does , In the automation test layer, try not to pay off the debt for the work that the unit test layer has not done .

                         

5、id,name,clas,xpath, css selector These attributes , Which one do you prefer the most , Why? ?

xpath and css Most flexible , So the other answers are not perfect .

6、 How to locate dynamically loaded elements on a page ?

Explicit waiting

7、 How to locate elements with dynamic attributes ?

Find out the law of dynamic change of attributes , Then generate dynamic attributes according to the context .

After clicking on the link ,selenium Whether it will automatically wait for the page to load ?java binding After clicking the link, it will automatically wait for the page to load .

8、selenium What is the principle of ?

selenium The principle of involves 3 Parts of , Namely

  • browser
  • driver: We usually download driver
  • client: That's the code we wrote

client In fact, I don't know how the browser works , however driver know , stay selenium After the start ,driver In fact, it acts as a server , Follow client Communicate with the browser ,client according to webdriver The protocol sends a request to driver,driver Resolve request , And perform corresponding operations on the browser , And return the execution result to client. This is it. selenium How it works .

9、webdriver What is your agreement ?

client And driver Agreement between , No matter what client It's using java Implementation or c# Realization , Just pass this Agreement ,client Can accurately tell drier What it does and how it does it .

webdriver The agreement itself is http agreement , Data transmission uses json. Here you are webdriver All aspects of the agreement endpoint, You can see this at a glance endpoints covers selenium All functions of .

10、 Which is used when starting the browser webdriver agreement ?

New Session, If created successfully , return sessionId and capabilities.

11、 What is? page object Design patterns ?

To put it simply, use class To represent the page under test . stay class Define the elements on the page and some methods specific to the page .

​​​​​​​

 

原网站

版权声明
本文为[Software testing Lao Mo]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206120907193816.html