Answer: There are eight ways to locate elements in web automation. Regarding names, there are three: name, class_name, tag_name, and regarding links, there are two: link_text, and partial_link_text. One way is to locate by id. The remaining two ways are xpath and css locators, which locate elements using element paths.
If the element has an id attribute, I would use the id because it is simple, convenient, and provides the fastest locating. Next, I would consider xpath and css because many HTML tags do not have an id attribute.
Answer: First, find an attribute of the element that does not change. If all attributes are changing, then find a parent element with an attribute that remains constant and use hierarchical locating (adapt to changes using a constant reference point).
Answer: The HTTP protocol.
Answer: A single slash represents an absolute path locator, while a double slash represents a relative path locator. An absolute path starts from the root of the HTML document and represents the element's path. A relative path selects an element based on a reference point and represents the element's path relative to that reference point.
Answer: Selenium primarily has three validation points:
① Checking the page title ② Checking specific text ③ Checking specific elements (text boxes, dropdown menus, tables, etc.)
Answer: Use the clear() method.
driver.find_element().clear()
Answer: driver.back() # Go back driver.forward() # Go forward
Answer: Both methods are used to find elements.
find_element() finds a single page element and returns a WebElement object.
find_elements() finds all elements that match the criteria and returns a collection of elements.
Answer: By using assertions and comparing the actual result with the expected result.
Answer: There are three ways: explicit wait, implicit wait, and thread sleep.
Answer: ① Check the logs to confirm if the element exists on the current page. ② If it exists, check if the locator method is correct. ③ If the issue persists, check if the element is inside an iframe. If it is, switch to the iframe first and then locate the element. After performing the necessary operations, remember to exit the iframe.
Answer: ① Ask the developers to disable the captcha in the testing environment.
② Ask the developers to provide a universal captcha (a complex one that others cannot guess).
③ If it is an image captcha, you can use image recognition techniques (although it can be challenging with low accuracy). ④ Manually log in to the system first, save the successful login cookie, and bypass the captcha using the cookie. ⑤ Ask the developers for database access to retrieve the captcha from the database.
Answer: ① If it is a JavaScript alert, use switch_to.alert to locate the alert and then use accept(), dismiss(), or other methods to handle it. ② If it is a prompt related to a specific step in the system, you can click the close button or follow the instructions provided in the prompt.
Answer: ① Automation test cases are used for monitoring. Integrate them into Jenkins and create scheduled tasks for execution. ② Some test cases require regression testing before the product goes live. Bind the tasks to the development build task on Jenkins to trigger execution. ③ Some test cases do not need frequent execution. Create a task on Jenkins and manually build when needed.
Answer: In a data-driven framework, the test case logic resides in the test script. The test data is separated and stored outside the test script. The test data is retrieved from external files (such as Excel) and loaded into variables within the test script. These variables are used for input values and verification values.
In a keyword-driven framework, both data tables and keywords are developed. They are independent of the automation tool used to execute them. The design of the test can be done with or without the application. In keyword-driven testing, the functionality of the application under test is documented in a table, along with step-by-step instructions for each test.
Lastly, we hope that these QA automation interview questions will be helpful for your interview. Additionally, if you want to learn more about testing tools, feel free to visit WeTest, which provides various services including functional testing, automated testing, and more. It will be your best assistant.