Automation Testing
Automation Testing
Automation Testing
Automation Testing:
Automation Testing:
Automation testing is when software tools and scripts are used to control
the execution of tests and compare the actual outcome with the expected
outcome. It's like having a robot that can test software for you
automatically, saving time and effort compared to manual testing.
- XPath:
XPath is a query language used for selecting nodes from an XML or HTML
document. It allows you to navigate through the elements and attributes of
an XML/HTML structure to locate specific elements.
For example, if you have an HTML document with the following structure:
```html
<html>
<body>
<div id="content">
<h1>Welcome</h1>
<p>This is a paragraph.</p>
</div>
</body>
</html>
```
You can use XPath to identify elements based on their attributes or
position in the document. For instance:
- `/html/body/div` would select the `<div>` element.
- `/html/body/div/h1` would select the `<h1>` element.
- `/html/body/div/p` would select the `<p>` element.
XPath expressions can also use various functions, axes, and operators to
refine the selection criteria.
```python
from selenium import webdriver
In this script:
- We import the necessary module `webdriver` from `selenium`.
- We initiate a new instance of Chrome WebDriver.
- We navigate to the login page (replace `"https://example.com/login"`
with the actual URL of the login page).
- We locate the login button using XPath. Here, we're using a partial text
match with `contains(text(), 'Login')` assuming the button text contains
"Login". Adjust the XPath expression according to the actual HTML
structure.
- We perform a click action on the login button.
- Finally, we close the WebDriver session to release the resources.
Make sure you have the Selenium WebDriver for Python installed (`pip
install selenium`) and the appropriate WebDriver (e.g., ChromeDriver)
downloaded and configured.
Database Testing:
Database testing involves verifying that data is being stored, retrieved, and
manipulated correctly in a database. This includes checking data integrity,
validation rules, and database schema. It ensures that the data stored in
the database is accurate and consistent.
Selenium is a popular open-source automation testing framework used
for automating web browsers. It allows you to control web browsers
programmatically, mimicking user interactions such as clicking buttons,
filling forms, navigating pages, and verifying content. Essentially, Selenium
acts as a bridge between your code and the web browser, enabling you to
write scripts that interact with web applications just like a real user would.
Selenium is widely used in software testing for:
- Functional testing: Verifying that the application behaves as expected
from a user's perspective.
- Regression testing: Ensuring that new changes do not break existing
functionality.
- Cross-browser testing: Checking compatibility across different web
browsers.
- Performance testing: Automating repetitive tasks to evaluate system
performance.