Skip to content

Commit 726a7c6

Browse files
authored
Merge branch 'trunk' into elementNotVisibleException
2 parents 979bce2 + 88c7b5c commit 726a7c6

35 files changed

+774
-727
lines changed

examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public async Task PerformanceMetrics()
111111
var session = ((IDevTools)driver).GetDevToolsSession();
112112
var domains = session.GetVersionSpecificDomains<OpenQA.Selenium.DevTools.V130.DevToolsSessionDomains>();
113113

114-
await domains.Performance.Enable(new OpenQA.Selenium.DevTools.V13.Performance.EnableCommandSettings());
114+
await domains.Performance.Enable(new OpenQA.Selenium.DevTools.V130.Performance.EnableCommandSettings());
115115
var metricsResponse =
116116
await session.SendCommand<GetMetricsCommandSettings, GetMetricsCommandResponse>(
117117
new GetMetricsCommandSettings()
Lines changed: 97 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,101 @@
1+
// Licensed to the Software Freedom Conservancy (SFC) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The SFC licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
using System;
119
using Microsoft.VisualStudio.TestTools.UnitTesting;
20+
using OpenQA.Selenium;
21+
using OpenQA.Selenium.Chrome;
22+
23+
namespace SeleniumDocs.Interactions{
24+
25+
[TestClass]
26+
public class CookiesTest{
27+
28+
WebDriver driver = new ChromeDriver();
29+
30+
[TestMethod]
31+
public void addCookie(){
32+
driver.Url="https://www.selenium.dev/selenium/web/blank.html";
33+
// Add cookie into current browser context
34+
driver.Manage().Cookies.AddCookie(new Cookie("key", "value"));
35+
driver.Quit();
36+
}
37+
38+
[TestMethod]
39+
public void getNamedCookie(){
40+
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
41+
// Add cookie into current browser context
42+
driver.Manage().Cookies.AddCookie(new Cookie("foo", "bar"));
43+
// Get cookie details with named cookie 'foo'
44+
Cookie cookie = driver.Manage().Cookies.GetCookieNamed("foo");
45+
Assert.AreEqual(cookie.Value, "bar");
46+
driver.Quit();
47+
}
48+
49+
[TestMethod]
50+
public void getAllCookies(){
51+
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
52+
// Add cookies into current browser context
53+
driver.Manage().Cookies.AddCookie(new Cookie("test1", "cookie1"));
54+
driver.Manage().Cookies.AddCookie(new Cookie("test2", "cookie2"));
55+
// Get cookies
56+
var cookies = driver.Manage().Cookies.AllCookies;
57+
foreach (var cookie in cookies){
58+
if (cookie.Name.Equals("test1")){
59+
Assert.AreEqual("cookie1", cookie.Value);
60+
}
61+
if (cookie.Name.Equals("test2")){
62+
Assert.AreEqual("cookie2", cookie.Value);
63+
}
64+
}
65+
driver.Quit();
66+
}
67+
68+
[TestMethod]
69+
public void deleteCookieNamed(){
70+
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
71+
driver.Manage().Cookies.AddCookie(new Cookie("test1", "cookie1"));
72+
// delete cookie named
73+
driver.Manage().Cookies.DeleteCookieNamed("test1");
74+
driver.Quit();
75+
}
276

3-
namespace SeleniumDocs.Interactions
4-
{
5-
[TestClass]
6-
public class CookiesTest : BaseTest
7-
{
77+
[TestMethod]
78+
public void deleteCookieObject(){
79+
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
80+
Cookie cookie = new Cookie("test2", "cookie2");
81+
driver.Manage().Cookies.AddCookie(cookie);
82+
/*
83+
Selenium CSharp bindings also provides a way to delete
84+
cookie by passing cookie object of current browsing context
85+
*/
86+
driver.Manage().Cookies.DeleteCookie(cookie);
87+
driver.Quit();
88+
}
89+
90+
[TestMethod]
91+
public void deleteAllCookies(){
92+
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
93+
// Add cookies into current browser context
94+
driver.Manage().Cookies.AddCookie(new Cookie("test1", "cookie1"));
95+
driver.Manage().Cookies.AddCookie(new Cookie("test2", "cookie2"));
96+
// Delete All cookies
97+
driver.Manage().Cookies.DeleteAllCookies();
98+
driver.Quit();
99+
}
8100
}
9101
}

examples/dotnet/SeleniumDocs/SeleniumDocs.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.7.1" />
1111
<PackageReference Include="MSTest.TestAdapter" Version="3.6.0" />
1212
<PackageReference Include="MSTest.TestFramework" Version="3.6.0" />
13-
<PackageReference Include="Selenium.Support" Version="4.25.0" />
14-
<PackageReference Include="Selenium.WebDriver" Version="4.25.0" />
13+
<PackageReference Include="Selenium.Support" Version="4.26.1" />
14+
<PackageReference Include="Selenium.WebDriver" Version="4.26.1" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

examples/python/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pytest
3232
## Execute a specific example
3333
To run a specific Selenium Python example, use the following command:
3434
```bash
35-
python first_script.py
35+
pytest path/to/test_script.py
3636
```
3737

38-
Make sure to replace `first_script.py` with the path and name of the example you want to run.
38+
Make sure to replace `path/to/test_script.py` with the path and name of the example you want to run.

examples/python/tests/browsers/test_firefox.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,25 @@ def test_install_unsigned_addon_directory_slash(firefox_driver, addon_path_dir_s
129129
injected = driver.find_element(webdriver.common.by.By.ID, "webextensions-selenium-example")
130130

131131
assert injected.text == "Content injected by webextensions-selenium-example"
132+
133+
134+
def test_full_page_screenshot(firefox_driver):
135+
driver = firefox_driver
136+
137+
driver.get("https://www.selenium.dev")
138+
139+
driver.save_full_page_screenshot("full_page_screenshot.png")
140+
141+
assert os.path.exists("full_page_screenshot.png")
142+
143+
driver.quit()
144+
145+
146+
def test_set_context(firefox_driver):
147+
driver = firefox_driver
148+
149+
with driver.context(driver.CONTEXT_CHROME):
150+
driver.execute_script("console.log('Inside Chrome context');")
151+
152+
# Check if the context is back to content
153+
assert driver.execute("GET_CONTEXT")["value"] == "content"

examples/python/tests/drivers/test_http_client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010

1111
@pytest.mark.skipif(sys.platform == "win32", reason="Gets stuck on Windows, passes locally")
12-
@pytest.mark.sanity
1312
def test_start_remote_with_client_config(grid_server):
1413
proxy = Proxy({"proxyType": ProxyType.AUTODETECT})
1514
retries = Retry(connect=2, read=2, redirect=2)
1615
timeout = Timeout(connect=300, read=3600)
1716
client_config = ClientConfig(remote_server_addr=grid_server,
1817
proxy=proxy,
19-
init_args_for_pool_manager={"retries": retries, "timeout": timeout},
18+
init_args_for_pool_manager={
19+
"init_args_for_pool_manager": {"retries": retries, "timeout": timeout}},
2020
ca_certs=_get_resource_path("tls.crt"),
2121
username="admin", password="myStrongPassword")
2222
options = webdriver.ChromeOptions()
@@ -26,7 +26,6 @@ def test_start_remote_with_client_config(grid_server):
2626

2727

2828
@pytest.mark.skipif(sys.platform == "win32", reason="Gets stuck on Windows, passes locally")
29-
@pytest.mark.sanity
3029
def test_start_remote_ignore_certs(grid_server):
3130
proxy = Proxy({"proxyType": ProxyType.AUTODETECT})
3231
client_config = ClientConfig(remote_server_addr=grid_server,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
browser = "chrome" # --browser BROWSER
2+
driver = "chromedriver" # --driver DRIVER
3+
browser-version = "106" # --browser-version BROWSER_VERSION
4+
driver-version = "106.0.5249.61" # --driver-version DRIVER_VERSION
5+
browser-path = "/usr/bin/google-chrome" # --browser-path BROWSER_PATH
6+
driver-mirror-url = "https://custom-driver-mirror.com" # --driver-mirror-url DRIVER_MIRROR_URL
7+
browser-mirror-url = "https://custom-browser-mirror.com" # --browser-mirror-url BROWSER_MIRROR_URL
8+
output = "LOGGER" # --output OUTPUT
9+
os = "linux" # --os OS
10+
arch = "x64" # --arch ARCH
11+
proxy = "myproxy:8080" # --proxy PROXY
12+
timeout = 300 # --timeout TIMEOUT
13+
offline = true # --offline
14+
force-browser-download = true # --force-browser-download
15+
avoid-browser-download = false # --avoid-browser-download
16+
debug = true # --debug
17+
trace = true # --trace
18+
cache-path = "/custom/cache/path" # --cache-path CACHE_PATH
19+
ttl = 3600 # --ttl TTL
20+
language-binding = "Python" # --language-binding LANGUAGE
21+
avoid-stats = true # --avoid-stats

0 commit comments

Comments
 (0)