|
| 1 | +--- |
| 2 | +title: "Chrome DevTools Network Features" |
| 3 | +linkTitle: "Network" |
| 4 | +weight: 4 |
| 5 | +description: > |
| 6 | + Network features using CDP. |
| 7 | +--- |
| 8 | + |
| 9 | +{{% pageinfo color="warning" %}} |
| 10 | +While Selenium 4 provides direct access to the Chrome DevTools Protocol, these |
| 11 | +methods will eventually be removed when WebDriver BiDi implemented. |
| 12 | +{{% /pageinfo %}} |
| 13 | + |
| 14 | + |
| 15 | +## Basic authentication |
| 16 | + |
| 17 | +Some applications make use of browser authentication to secure pages. |
| 18 | +It used to be common to handle them in the URL, but browsers stopped supporting this. |
| 19 | +With this code you can insert the credentials into the header when necessary |
| 20 | + |
| 21 | +{{< tabpane text=true >}} |
| 22 | +{{% tab header="Java" %}} |
| 23 | +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L41-L43" >}} |
| 24 | +{{% /tab %}} |
| 25 | +{{% tab header="Python" %}} |
| 26 | +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_network.py#L13-15" >}} |
| 27 | +{{% /tab %}} |
| 28 | +{{% tab header="CSharp" %}} |
| 29 | +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs#L25-L32" >}} |
| 30 | +{{% /tab %}} |
| 31 | +{{% tab header="Ruby" %}} |
| 32 | +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/network_spec.rb#L9-L11" >}} |
| 33 | +{{% /tab %}} |
| 34 | +{{% tab header="JavaScript" %}} |
| 35 | +{{< badge-implementation >}} |
| 36 | +{{% /tab %}} |
| 37 | +{{% tab header="Kotlin" %}} |
| 38 | +{{< badge-implementation >}} |
| 39 | +{{% /tab %}} |
| 40 | +{{< /tabpane >}} |
| 41 | + |
| 42 | + |
| 43 | +## Network Interception |
| 44 | + |
| 45 | +Both requests and responses can be recorded or transformed. |
| 46 | + |
| 47 | +#### Response information |
| 48 | + |
| 49 | +{{< tabpane text=true >}} |
| 50 | +{{% tab header="Java" %}} |
| 51 | +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L56-L65" >}} |
| 52 | +{{% /tab %}} |
| 53 | +{{% tab header="Python" %}} |
| 54 | +{{< badge-implementation >}} |
| 55 | +{{% /tab %}} |
| 56 | +{{% tab header="CSharp" %}} |
| 57 | +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs#L46-L51" >}} |
| 58 | +{{% /tab %}} |
| 59 | +{{% tab header="Ruby" %}} |
| 60 | +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/network_spec.rb#L20-L24" >}} |
| 61 | +{{% /tab %}} |
| 62 | +{{% tab header="JavaScript" %}} |
| 63 | +{{< badge-implementation >}} |
| 64 | +{{% /tab %}} |
| 65 | +{{% tab header="Kotlin" %}} |
| 66 | +{{< badge-code >}} |
| 67 | +{{% /tab %}} |
| 68 | +{{< /tabpane >}} |
| 69 | + |
| 70 | +#### Response transformation |
| 71 | + |
| 72 | +{{< tabpane text=true >}} |
| 73 | +{{% tab header="Java" %}} |
| 74 | +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L75-L85" >}} |
| 75 | +{{% /tab %}} |
| 76 | +{{% tab header="Python" %}} |
| 77 | +{{< badge-implementation >}} |
| 78 | +{{% /tab %}} |
| 79 | +{{% tab header="CSharp" %}} |
| 80 | +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs#L62-L73" >}} |
| 81 | +{{% /tab %}} |
| 82 | +{{% tab header="Ruby" %}} |
| 83 | +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/network_spec.rb#L31-L35" >}} |
| 84 | +{{% /tab %}} |
| 85 | +{{% tab header="JavaScript" %}} |
| 86 | +{{< badge-implementation >}} |
| 87 | +{{% /tab %}} |
| 88 | +{{% tab header="Kotlin" %}} |
| 89 | +{{< badge-code >}} |
| 90 | +{{% /tab %}} |
| 91 | +{{< /tabpane >}} |
| 92 | + |
| 93 | + |
| 94 | +#### Request interception |
| 95 | + |
| 96 | +{{< tabpane text=true >}} |
| 97 | +{{% tab header="Java" %}} |
| 98 | +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L97-L110" >}} |
| 99 | +{{% /tab %}} |
| 100 | +{{% tab header="Python" %}} |
| 101 | +{{< badge-implementation >}} |
| 102 | +{{% /tab %}} |
| 103 | +{{% tab header="CSharp" %}} |
| 104 | +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs#L85-L97" >}} |
| 105 | +{{% /tab %}} |
| 106 | +{{% tab header="Ruby" %}} |
| 107 | +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/network_spec.rb#L42-L46" >}} |
| 108 | +{{% /tab %}} |
| 109 | +{{% tab header="JavaScript" %}} |
| 110 | +{{< badge-implementation >}} |
| 111 | +{{% /tab %}} |
| 112 | +{{% tab header="Kotlin" %}} |
| 113 | +{{< badge-code >}} |
| 114 | +{{% /tab %}} |
| 115 | +{{< /tabpane >}} |
| 116 | + |
| 117 | + |
| 118 | +## Performance Metrics |
| 119 | + |
| 120 | +{{< tabpane text=true >}} |
| 121 | +{{% tab header="Java" %}} |
| 122 | +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L125-L126" >}} |
| 123 | +{{% /tab %}} |
| 124 | +{{% tab header="Python" %}} |
| 125 | +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_logging.py#L26-L28" >}} |
| 126 | +{{% /tab %}} |
| 127 | +{{% tab header="CSharp" %}} |
| 128 | +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs#L114-L118" >}} |
| 129 | +{{% /tab %}} |
| 130 | +{{% tab header="Ruby" %}} |
| 131 | +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/network_spec.rb#L56-L57" >}} |
| 132 | +{{% /tab %}} |
| 133 | +{{% tab header="JavaScript" %}} |
| 134 | +{{< badge-implementation >}} |
| 135 | +{{% /tab %}} |
| 136 | +{{% tab header="Kotlin" %}} |
| 137 | +{{< badge-code >}} |
| 138 | +{{% /tab %}} |
| 139 | +{{< /tabpane >}} |
| 140 | + |
| 141 | + |
| 142 | +## Setting Cookies |
| 143 | + |
| 144 | +{{< tabpane text=true >}} |
| 145 | +{{% tab header="Java" %}} |
| 146 | +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L142-L157" >}} |
| 147 | +{{% /tab %}} |
| 148 | +{{% tab header="Python" %}} |
| 149 | +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_logging.py#L37-L44" >}} |
| 150 | +{{% /tab %}} |
| 151 | +{{% tab header="CSharp" %}} |
| 152 | +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs#L136-L143" >}} |
| 153 | +{{% /tab %}} |
| 154 | +{{% tab header="Ruby" %}} |
| 155 | +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/network_spec.rb#L68-L71" >}} |
| 156 | +{{% /tab %}} |
| 157 | +{{% tab header="JavaScript" %}} |
| 158 | +{{< badge-implementation >}} |
| 159 | +{{% /tab %}} |
| 160 | +{{% tab header="Kotlin" %}} |
| 161 | +{{< badge-code >}} |
| 162 | +{{% /tab %}} |
| 163 | +{{< /tabpane >}} |
| 164 | + |
| 165 | + |
| 166 | +## Waiting for Downloads |
| 167 | + |
| 168 | +{{< tabpane text=true >}} |
| 169 | +{{% tab header="Java" %}} |
| 170 | +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L171-L176" >}} |
| 171 | +{{% /tab %}} |
| 172 | +{{% tab header="Python" %}} |
| 173 | +{{< badge-implementation >}} |
| 174 | +{{% /tab %}} |
| 175 | +{{% tab header="CSharp" %}} |
| 176 | +{{< badge-implementation >}} |
| 177 | +{{% /tab %}} |
| 178 | +{{% tab header="Ruby" %}} |
| 179 | +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/network_spec.rb#L82-L88" >}} |
| 180 | +{{% /tab %}} |
| 181 | +{{% tab header="JavaScript" %}} |
| 182 | +{{< badge-implementation >}} |
| 183 | +{{% /tab %}} |
| 184 | +{{% tab header="Kotlin" %}} |
| 185 | +{{< badge-code >}} |
| 186 | +{{% /tab %}} |
| 187 | +{{< /tabpane >}} |
0 commit comments