|
| 1 | +--- |
| 2 | +id: kane-ai-network-assertions |
| 3 | +title: Network Logs Assertions |
| 4 | +hide_title: false |
| 5 | +sidebar_label: Network Logs Assertions |
| 6 | +description: In this detailed guide, you will learn how you can add network logs assertions in your tests. |
| 7 | +keywords: |
| 8 | + - network |
| 9 | + - network logs assertion |
| 10 | + - assertion |
| 11 | + - lambdatest kaneai |
| 12 | +url: https://www.lambdatest.com/support/docs/kane-ai-network-assertions |
| 13 | +site_name: LambdaTest |
| 14 | +slug: kane-ai-network-assertions/ |
| 15 | +--- |
| 16 | + |
| 17 | +import Tabs from '@theme/Tabs'; |
| 18 | +import TabItem from '@theme/TabItem'; |
| 19 | + |
| 20 | +<script type="application/ld+json" |
| 21 | + dangerouslySetInnerHTML={{ __html: JSON.stringify({ |
| 22 | + "@context": "https://schema.org", |
| 23 | + "@type": "BreadcrumbList", |
| 24 | + "itemListElement": [{ |
| 25 | + "@type": "ListItem", |
| 26 | + "position": 1, |
| 27 | + "name": "Home", |
| 28 | + "item": "https://www.lambdatest.com" |
| 29 | + },{ |
| 30 | + "@type": "ListItem", |
| 31 | + "position": 2, |
| 32 | + "name": "Support", |
| 33 | + "item": "https://www.lambdatest.com/support/docs/" |
| 34 | + },{ |
| 35 | + "@type": "ListItem", |
| 36 | + "position": 3, |
| 37 | + "name": "ANetwork Assertions", |
| 38 | + "item": "https://www.lambdatest.com/support/docs/kane-ai-network-assertions" |
| 39 | + }] |
| 40 | + }) |
| 41 | + }} |
| 42 | +></script> |
| 43 | +# Network Logs Assertions |
| 44 | +The **Network Logs Assertions** feature in KaneAI enables you to test and validate the behavior of your application at the **network layer**. |
| 45 | +This is useful when you need to ensure that API calls, response codes, payloads, or request timings meet expected conditions during your test executions. |
| 46 | + |
| 47 | +# Let's see how to add Network Logs Assertions in a Test |
| 48 | + |
| 49 | +- **Start a test session** (Desktop or Mobile Web). |
| 50 | + |
| 51 | +- All network calls are automatically recorded in the background as you navigate through your application, you can see the Network calls made so far through the **Assert Network Logs** option available in the " / " commands. |
| 52 | + |
| 53 | +<img loading="lazy" src={require('../assets/images/kane-ai/features/network-assertions/hit-network-req.png').default} alt="Image" className="doc_img img_center"/> |
| 54 | + |
| 55 | +- Here you will find all the Network requests made in this session so far and **having the Json data format**, you can filter the requests on basis of **Status Code** or **HTTP Methods**: |
| 56 | + |
| 57 | +<img loading="lazy" src={require('../assets/images/kane-ai/features/network-assertions/network-logs.png').default} alt="Image" className="doc_img img_center"/> |
| 58 | + |
| 59 | +- Select the specific key's that you want to add in the assertion from the **Request Headers**. |
| 60 | + |
| 61 | +<img loading="lazy" src={require('../assets/images/kane-ai/features/network-assertions/network-log-headers.png').default} alt="Image" className="doc_img img_center"/> |
| 62 | + |
| 63 | +- To add **Request** or **Response blocks** in assertions click on the `Add Assertion` button. All the chosen values will be validated in a single step. |
| 64 | + |
| 65 | +<img loading="lazy" src={require('../assets/images/kane-ai/features/network-assertions/network-log-response.png').default} alt="Image" className="doc_img img_center"/> |
| 66 | + |
| 67 | +- Once added, the request will be stored as a **variable**. KaneAI then makes assertions based on this variable. |
| 68 | + |
| 69 | +<img loading="lazy" src={require('../assets/images/kane-ai/features/network-assertions/network-assertion-block.png').default} alt="Image" className="doc_img img_center"/> |
| 70 | + |
| 71 | +#### How to validate a specific object in request or response of an API? |
| 72 | + |
| 73 | +- You can reuse the request later in your test using the familiar `{{variable}}` syntax. |
| 74 | + |
| 75 | +<img loading="lazy" src={require('../assets/images/kane-ai/features/network-assertions/network-req-variable.png').default} alt="Image" className="doc_img img_center"/> |
| 76 | + |
| 77 | +- The stored variable is in **JSON format**, so you can easily access nested values with dot-notation (e.g., `header.status`). |
| 78 | + |
| 79 | +<img loading="lazy" src={require('../assets/images/kane-ai/features/network-assertions/child-variables.png').default} alt="Image" className="doc_img img_center" style={{width: '60%'}}/> |
| 80 | + |
| 81 | +:::note |
| 82 | +This feature is not enabled for all users. Please contact our support team to request access. |
| 83 | +::: |
0 commit comments