"Fossies" - the Fresh Open Source Software Archive 
Member "selenium-selenium-4.8.1/dotnet/test/common/NavigationTest.cs" (17 Feb 2023, 2912 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C# source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 using System;
2 using NUnit.Framework;
3
4 namespace OpenQA.Selenium
5 {
6
7 [TestFixture]
8 public class NavigationTest : DriverTestFixture
9 {
10
11 [Test]
12 [NeedsFreshDriver(IsCreatedBeforeTest = true)]
13 public void ShouldNotHaveProblemNavigatingWithNoPagesBrowsed()
14 {
15 INavigation navigation;
16 navigation = driver.Navigate();
17 navigation.Back();
18 navigation.Forward();
19 }
20
21 [Test]
22 public void ShouldGoBackAndForward()
23 {
24 INavigation navigation;
25 navigation = driver.Navigate();
26
27 driver.Url = macbethPage;
28 driver.Url = simpleTestPage;
29
30 navigation.Back();
31 Assert.AreEqual(macbethTitle, driver.Title);
32
33 navigation.Forward();
34 Assert.AreEqual(simpleTestTitle, driver.Title);
35 }
36
37 [Test]
38 public void ShouldAcceptInvalidUrlsUsingUris()
39 {
40 INavigation navigation;
41 navigation = driver.Navigate();
42 Assert.That(() => navigation.GoToUrl((Uri)null), Throws.InstanceOf<ArgumentNullException>());
43 // new Uri("") and new Uri("isidsji30342??éåµñ©æ")
44 // throw an exception, so we needn't worry about them.
45 }
46
47 [Test]
48 public void ShouldGoToUrlUsingString()
49 {
50 INavigation navigation;
51 navigation = driver.Navigate();
52
53 navigation.GoToUrl(macbethPage);
54 Assert.AreEqual(macbethTitle, driver.Title);
55
56 // We go to two pages to ensure that the browser wasn't
57 // already at the desired page through a previous test.
58 navigation.GoToUrl(simpleTestPage);
59 Assert.AreEqual(simpleTestTitle, driver.Title);
60 }
61
62 [Test]
63 public void ShouldGoToUrlUsingUri()
64 {
65 Uri macBeth = new Uri(macbethPage);
66 Uri simpleTest = new Uri(simpleTestPage);
67 INavigation navigation;
68 navigation = driver.Navigate();
69
70 navigation.GoToUrl(macBeth);
71 Assert.AreEqual(driver.Title, macbethTitle);
72
73 // We go to two pages to ensure that the browser wasn't
74 // already at the desired page through a previous test.
75 navigation.GoToUrl(simpleTest);
76 Assert.AreEqual(simpleTestTitle, driver.Title);
77 }
78
79 [Test]
80 public void ShouldRefreshPage()
81 {
82 driver.Url = javascriptPage;
83 IWebElement changedDiv = driver.FindElement(By.Id("dynamo"));
84 driver.FindElement(By.Id("updatediv")).Click();
85
86 Assert.AreEqual("Fish and chips!", changedDiv.Text);
87 driver.Navigate().Refresh();
88
89 changedDiv = driver.FindElement(By.Id("dynamo"));
90 Assert.AreEqual("What's for dinner?", changedDiv.Text);
91 }
92
93 }
94 }