Software testing interview questions automation face-to-face sharing-this is the secret of high salary!

Hello, your good friend is here! Guess what dry goods I bring to you today? Recently, when many small partners go out for interviews, they are often asked interview questions related to automated testing. Therefore, today I specially sorted out some interview questions related to automated testing that are often asked by companies. Stop, let's store it up first, don't find it when the time comes, and if you ask me for it again, I will pretend that I don't know you.

Okay, let's not talk nonsense, let's go straight to the dry goods.

[Message: Automated testing interview questions, free access] 

1.  The first most frequently asked question: What are the element positioning methods you are most familiar with?

  1. id : get the element according to the id, and return a single element, and the id value is generally unique;
  2. name : locate according to the name attribute of the element;
  3. tagName: locate according to the tag name of the element;
  4. className: locate according to the style class value of the element;
  5. linkText : locate according to the text value of the hyperlink;
  6. partialLinkText : locate according to the partial text value of the hyperlink;
  7. cssSelector : css selector positioning;
  8. xpath : locate by the path of the element;
  9. Highest priority: ID
  10. Second priority: name
  11. Priority again: CSS selector
  12. Priority again: Xpath

Second, if an element cannot be positioned, what factors do you generally consider?

This is often encountered in our actual automated testing process, which can generally be considered from the following aspects:

1. The element positioning method is wrong, you can check whether the element positioning method is correct

2. The loading of page elements is too slow, and the waiting time needs to be added

3. There is a frame on the page, you need to switch to the correct frame before positioning

3. If an element cannot be positioned, what factors do you generally consider?

This is often encountered in our actual automated testing process, which can generally be considered from the following aspects:

1. The element positioning method is wrong, you can check whether the element positioning method is correct

2. The loading of page elements is too slow, and the waiting time needs to be added

3. There is a frame on the page, you need to switch to the correct frame before positioning

4. Tell me about the automated testing framework you know

1、RobotFramework

2、Pytest

3、Unittest

4、PyUnit

5. There are several waiting methods in automated testing. Is there any difference between them?

1. Forced waiting

time.sleep(3): This waiting method means that you must wait for 3 seconds before executing subsequent code. This form is not flexible enough. It is possible that the page has been loaded within 3 seconds, but it still needs to wait 3 seconds before proceeding to the next step.

2. Implicit waiting

Implicitlywait: This form of waiting will continue to look for elements within the time, and you can stop waiting after you find them. But this form needs to wait for the entire page to load before proceeding to the next step.

3. Explicit wait

WebDriverWait: This form of waiting is to wait for an element. As long as the element is loaded, the subsequent code can be executed. This form is more flexible.

6. What is the PO mode, and what are its three layers? What is the relationship between the three?

PO mode is an automated test design idea, which regards a page as an object, and the elements of the page as the attributes and behaviors of the object. PO mode generally has three layers:

Base layer: Encapsulate some of the most basic methods

Page object layer: element positioning, page operations, etc.

Test case layer: business logic, data-driven

The relationship between these three layers:

The page object layer inherits the base layer, and the test case layer calls the page object layer

7. What is the process of automated testing?

1. Write an automated test plan

2. Design automated test cases

3. Develop automated test scripts

4. Execute automated test scripts

5. Generate automated test reports and analyze test results

8. Can the test script you write run on different browsers?

Of course, the use cases I wrote can run on the three browsers of IE, Firefox and Google. The idea of ​​implementation is to encapsulate a method and
pass in a browser string respectively. If IE is passed in, IE is used, if FireFox is passed in, FireFox is used, and if Chrome is passed in,
Chrome browser is used, and what browser is used Can be configured in the general ini configuration file. It should be noted that
the drivers used by each browser are different.

9. During your automation process, did you encounter any problems? For example

This question, be it automation or any job, will be asked. I mainly want to know how you solve the problem, so as to infer your
ability to analyze and solve the problem. Of course, there are problems and challenges, the main points are as follows: Frequently change the UI, often modify the
code in the page object to run the use case error reporting and processing, for example, the element is not visible, the element cannot be found, such abnormal test scripts are reused as much as possible Multi-code reuse
Page element positioning problems caused by some new frameworks, such as ck editor, dynamic tables, etc.

Ten. Both xpath and css positioning are relatively powerful, so what is the difference between them?

① CSS locator is faster than XPath locator, because css works with html, and its realization principle is the principle of matching objects, while
xpath works with xml, and its realization principle is the principle of traversal, so the two are designed , css performance is better
②Css can directly match part of the class attribute, and XPath is consistent with ordinary attributes for class
③xpath can match ancestor elements, css can’t
④Search for sibling elements, Css can only find elements behind the element (siblings) , can't look forward (brother and sister)

11. List comprehension

List comprehensions (aka list comprehensions) provide a concise way to create lists.

It is structured by enclosing an expression in square brackets, followed by a for statement, followed by zero or more for or if statements. That expression is arbitrary, meaning you can put any type of object in the list. The return result will be a new list, generated after the expression in the context of the if and for statements has been run.

  1. The execution order of the list comprehension: each statement is a nested relationship, the second statement on the left is the outermost layer, one level to the right, and the first statement on the left is the last level.
[x*y for x in range(1,5) if x > 2 for y in range(1,4) if y < 3]

His order of execution is:

for x in range(1,5)
    if x > 2
        for y in range(1,4)
            if y < 3
                x*y
  1. Please use list derivation to generate a new list based on a list.
    According to a certain rule: square.
    One line of code to achieve.
# 请用列表导式实现,根据一个列表生成一个新的列表
# 根据某种规则:求平方
# 一行代码实现


# 第一种并没有实现1和2
list1 = [1,2,3,4,5,6]
# list2 = []
# for i in list1:
#     print(i)
#     r = i * i
#     list2.append(r)
# print(list2)

# 第二种方法可实现
# 用map函数也可以实现
# result = map(lambda x:x*x,list1)
# print(list(result))

# 第三种方法可实现
# 列表推导式实现
# result = [i*i for i in list1]
# print(result)
result = [i**3 for i in list1]
print(result)

#最终只返回大于60的数字,补充i不是返回的结果,i是列表中的元素

result = [i**3 for i in list1 if i**3 > 60]
print(result)

 
# 第四种方法可实现
# 只计算大于3的数字即可
result = [i**3 for i in list1 if i > 3]
print(result)
# 只计算小于3的数字即可
result = [i**3 for i in list1 if i < 3]
print(result)

12. The sorting idea of ​​bubble sorting

# 请使用冒泡排序法,将以下列表中的元素从小到大进行排序
list1 = [5,3,2,10,15,13]
# 实现思路是:两个相邻的数字进行比较,大的向上浮,小的向下沉,最后一个元素是最大的
"""
现在的列表:[5,3,2,10,15,13]
1、比较5和3,具体谁大,name5大于3,所以它们两个袁术的位置就要进行交换
[3,5,2,10,15,13]
2、比较5和2,此时的列表[3,5,2,10,15,13],5比2大,所以5和2交换位置
[3,2,5,10,15,13]
3、比较5和10,那么位置不动
[3,2,5,10,15,13]
4、比较10和15,那么10和15小,所以位置不动
[3,2,5,10,15,13]
5、比较15和13,那么15比13大,所以它们交换位置
[3,2,5,10,13,15]
----------------第一轮比较结束----------
6、比较3和2,那么3比2大,所以热门交换位置
[2,3,5,10,13,15]
7、比较3和5,那么3和5小,所以它们的位置不变
[2,3,5,10,13,15]
8、比较5和10,那么5比10小,所以它们的位置不变
[2,3,5,10,13,15]
9、比较10和13,那么10比13小,所以它们的位置不变
[2,3,5,10,13,15]
经过第一轮的比较,我们已经知道了最后一个元素就是最大的,所以这里13和15就不用比较了
----------------第二轮比较结束----------
10、比较2和3,那么2比3小,所以它们的位置不变
[2,3,5,10,13,15]
11、比较3和5
[2,3,5,10,13,15]
12、比较5和10
[2,3,5,10,13,15]
----------------第三轮比较结束----------
13、比较2和3,那么2比3小,所以它们的位置不变
[2,3,5,10,13,15]
14、比较3和5
[2,3,5,10,13,15]
----------------第四轮比较结束----------
这个时候意味着后边的4个已经确认了他们的顺序
15、比较2和3,那么2比3小,所以它们的位置不变
[2,3,5,10,13,15]


[3,5,2,10,15,13]
[3,2,5,10,15,13]
[3,2,5,10,15,13]
[3,2,5,10,15,13]
[3,2,5,10,13,15]
[2,3,5,10,13,15]
[2,3,5,10,13,15]
[2,3,5,10,13,15]
[2,3,5,10,13,15]

[2,3,5,10,13,15]
[2,3,5,10,13,15]
[2,3,5,10,13,15]

[2,3,5,10,13,15]
[2,3,5,10,13,15]

[2,3,5,10,13,15]
[2,3,5,10,13,15]

"""

Fourteen. Bubble sorting method--code implementation

# 请使用冒泡排序法,将以下列表中的元素从小到大进行排序
list1 = [5,3,2,10,15,13]
# 实现思路是:两个相邻的数字进行比较,大的向上浮,小的向下沉,最后一个元素是最大的
"""
现在的列表:[5,3,2,10,15,13]
1、比较5和3,具体谁大,name5大于3,所以它们两个袁术的位置就要进行交换
[3,5,2,10,15,13]
2、比较5和2,此时的列表[3,5,2,10,15,13],5比2大,所以5和2交换位置
[3,2,5,10,15,13]
3、比较5和10,那么位置不动
[3,2,5,10,15,13]
4、比较10和15,那么10和15小,所以位置不动
[3,2,5,10,15,13]
5、比较15和13,那么15比13大,所以它们交换位置
[3,2,5,10,13,15]
----------------第一轮比较结束----------
6、比较3和2,那么3比2大,所以热门交换位置
[2,3,5,10,13,15]
7、比较3和5,那么3和5小,所以它们的位置不变
[2,3,5,10,13,15]
8、比较5和10,那么5比10小,所以它们的位置不变
[2,3,5,10,13,15]
9、比较10和13,那么10比13小,所以它们的位置不变
[2,3,5,10,13,15]
经过第一轮的比较,我们已经知道了最后一个元素就是最大的,所以这里13和15就不用比较了
----------------第二轮比较结束----------
10、比较2和3,那么2比3小,所以它们的位置不变
[2,3,5,10,13,15]
11、比较3和5
[2,3,5,10,13,15]
12、比较5和10
[2,3,5,10,13,15]
----------------第三轮比较结束----------
13、比较2和3,那么2比3小,所以它们的位置不变
[2,3,5,10,13,15]
14、比较3和5
[2,3,5,10,13,15]
----------------第四轮比较结束----------
这个时候意味着后边的4个已经确认了他们的顺序
15、比较2和3,那么2比3小,所以它们的位置不变
[2,3,5,10,13,15]



[3,2,5,10,13,15]
[3,2,5,10,15,13]
[3,2,5,10,15,13]
[3,2,5,10,15,13]
[3,5,2,10,15,13]
[5,3,2,10,15,13] 

"""
# 具体冒号排序的代码实现
def bubble_sort(blist):
    list_len = len(blist)
    print("传入参数列表的长度是{}".format(list_len))
    # 如何能够获取到相邻的两个元素
    # 外层循环就是用来控制轮次的
    for i in range(0,list_len-1):
        for j in  range(list_len-1):
            print("此时我们要排序的元素是{}和{}".format(blist[j],blist[j+1]))
            # 排序,交换位置
            if blist[j] > blist[j+1]:
                # 我们使用python特有的交换方法来进行交换
                  blist[j],blist[j+1] = blist[j+1],blist[j]
            print("此时的列表的形状是:{}".format(blist))
        print("========第{}轮比较结束========".format(i+1))
# bubble_sort(list1)

bubble_sort([3,5,67,89,90])

Print result:

传入参数列表的长度是5
此时我们要排序的元素是3和5
此时的列表的形状是:[3, 5, 67, 89, 90]
此时我们要排序的元素是5和67
此时的列表的形状是:[3, 5, 67, 89, 90]
此时我们要排序的元素是67和89
此时的列表的形状是:[3, 5, 67, 89, 90]
此时我们要排序的元素是89和90
此时的列表的形状是:[3, 5, 67, 89, 90]
========第1轮比较结束========
此时我们要排序的元素是3和5
此时的列表的形状是:[3, 5, 67, 89, 90]
此时我们要排序的元素是5和67
此时的列表的形状是:[3, 5, 67, 89, 90]
此时我们要排序的元素是67和89
此时的列表的形状是:[3, 5, 67, 89, 90]
此时我们要排序的元素是89和90
此时的列表的形状是:[3, 5, 67, 89, 90]
========第2轮比较结束========
此时我们要排序的元素是3和5
此时的列表的形状是:[3, 5, 67, 89, 90]
此时我们要排序的元素是5和67
此时的列表的形状是:[3, 5, 67, 89, 90]
此时我们要排序的元素是67和89
此时的列表的形状是:[3, 5, 67, 89, 90]
此时我们要排序的元素是89和90
此时的列表的形状是:[3, 5, 67, 89, 90]
========第3轮比较结束========
此时我们要排序的元素是3和5
此时的列表的形状是:[3, 5, 67, 89, 90]
此时我们要排序的元素是5和67
此时的列表的形状是:[3, 5, 67, 89, 90]
此时我们要排序的元素是67和89
此时的列表的形状是:[3, 5, 67, 89, 90]
此时我们要排序的元素是89和90
此时的列表的形状是:[3, 5, 67, 89, 90]
========第4轮比较结束========

Process finished with exit code 0

15. The idea and implementation of quick sort method

# 请使用快速排序法实现将以下列表中的元素从小到大的排序
list1 = [5,3,2,10,15,13]
"""
核心思想是
1、从列表中取出任意一个元素,但是我们一般取第一个
2、把这个取出米的元素作为比较的标准
3、把比这个元素小的放在左边
4、把比这个元素大的放在右边
"""
def quick_sort(quick_list):
    print("现在的列表是:{}".format(quick_list))
    if quick_list == []:
        print("------寻找结束,此时列表为空-------")
        return []
    first = quick_list[0]
    # 使用列表推导式加上递归实现
    print("开始寻找比第一个元素《《小》》的元素,第一个元素是{}".format(first))
    less = quick_sort([l for l in quick_list[1:] if l <first])
    print("开始寻找比第一个元素《《大》》的元素,第一个元素是{}".format(first))
    more = quick_sort([m for m in quick_list[1:] if m >= first])
    print("*****此时返回的列表是{}*****".format(less +[first] + more))
    return less +[first] + more
# print(quick_sort(list1))
print(quick_sort([4,2,56,35,78,46,89,1]))
打印结果:
现在的列表是:[4, 2, 56, 35, 78, 46, 89, 1]
开始寻找比第一个元素《《小》》的元素,第一个元素是4
现在的列表是:[2, 1]
开始寻找比第一个元素《《小》》的元素,第一个元素是2
现在的列表是:[1]
开始寻找比第一个元素《《小》》的元素,第一个元素是1
现在的列表是:[]
------寻找结束,此时列表为空-------
开始寻找比第一个元素《《大》》的元素,第一个元素是1
现在的列表是:[]
------寻找结束,此时列表为空-------
*****此时返回的列表是[1]*****
开始寻找比第一个元素《《大》》的元素,第一个元素是2
现在的列表是:[]
------寻找结束,此时列表为空-------
*****此时返回的列表是[1, 2]*****
开始寻找比第一个元素《《大》》的元素,第一个元素是4
现在的列表是:[56, 35, 78, 46, 89]
开始寻找比第一个元素《《小》》的元素,第一个元素是56
现在的列表是:[35, 46]
开始寻找比第一个元素《《小》》的元素,第一个元素是35
现在的列表是:[]
------寻找结束,此时列表为空-------
开始寻找比第一个元素《《大》》的元素,第一个元素是35
现在的列表是:[46]
开始寻找比第一个元素《《小》》的元素,第一个元素是46
现在的列表是:[]
------寻找结束,此时列表为空-------
开始寻找比第一个元素《《大》》的元素,第一个元素是46
现在的列表是:[]
------寻找结束,此时列表为空-------
*****此时返回的列表是[46]*****
*****此时返回的列表是[35, 46]*****
开始寻找比第一个元素《《大》》的元素,第一个元素是56
现在的列表是:[78, 89]
开始寻找比第一个元素《《小》》的元素,第一个元素是78
现在的列表是:[]
------寻找结束,此时列表为空-------
开始寻找比第一个元素《《大》》的元素,第一个元素是78
现在的列表是:[89]
开始寻找比第一个元素《《小》》的元素,第一个元素是89
现在的列表是:[]
------寻找结束,此时列表为空-------
开始寻找比第一个元素《《大》》的元素,第一个元素是89
现在的列表是:[]
------寻找结束,此时列表为空-------
*****此时返回的列表是[89]*****
*****此时返回的列表是[78, 89]*****
*****此时返回的列表是[35, 46, 56, 78, 89]*****
*****此时返回的列表是[1, 2, 4, 35, 46, 56, 78, 89]*****
[1, 2, 4, 35, 46, 56, 78, 89]

Process finished with exit code 0

16. Network protocol layering

  • Network Protocol Layering - OSI Model

 

  • Network protocol layering-OSI model-illustration

 

  • OSI seven-layer protocol and TCP/IP five-layer protocol and corresponding network protocol

 

Seventeen. Captcha problem in web automation testing

  1. How did you solve the captcha issue when logging in?
  • Classification of verification codes
  1. Ideas for solving verification codes
  • closure
  • universal verification code
  • bypass
  1. How to handle verification codes

     (1)取消验证码----->找开发把验证码代码注释掉,适用于测试环境
    
     (2)万能验证码----->找开发把验证码值设置为恒定的,适用于生产环境
    
     (3)识别验证码----->识别成功率不能保证,且只能识别比较简单的验证码
    
     (4)cookie跳过验证码--->通过记录cookie,实现自动登录
    
     (5)半自动化输入验证码---->遇到验证码时暂停一段时间,手动输入验证码
    

18. How to manage automated test cases?

  • According to the size of the project
  • According to the stage of the project (at the beginning of the project, project iteration, project stabilization)

19. When to conduct automated testing

When the project is relatively stable

  • Looking at the environment of automated test execution from the project process

Twenty. id, name, class, xpath, css selector these attributes, which one do you prefer, and why?

Almost all elements of css and xpath can be located, but their shortcoming is that the position is easy to change after the element is changed on the page, so the id or name is used first.

21. How to locate the dynamically loaded elements on the page?

Trigger the event of the dynamically loaded element until the dynamic element appears for positioning

22. How to locate elements whose attributes change dynamically?

xpath or css locates through siblings, parents, and children 

After clicking a link, does Selenium automatically wait for the page to load?

Will do

--------------------------------------

Do you dare to spend 3 days memorizing these 100 software testing interview questions! After memorizing these interview questions, the offer is not at hand! !

epilogue

This post ends here, and finally, I hope that friends who read this post can gain something.

 How to get it: Leave a message [Software Test Interview Questions]

If you think the article is not bad, please like, share, and leave a message , because this will be the strongest motivation for me to continue to output more high-quality articles!

Guess you like

Origin blog.csdn.net/weixin_67553250/article/details/130805394