"Fossies" - the Fresh Open Source Software Archive

Member "selenium-selenium-4.8.1/dotnet/src/webdriver/Navigator.cs" (17 Feb 2023, 2730 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. For more information about "Navigator.cs" see the Fossies "Dox" file reference documentation.

    1 // <copyright file="Navigator.cs" company="WebDriver Committers">
    2 // Licensed to the Software Freedom Conservancy (SFC) under one
    3 // or more contributor license agreements. See the NOTICE file
    4 // distributed with this work for additional information
    5 // regarding copyright ownership. The SFC licenses this file
    6 // to you under the Apache License, Version 2.0 (the "License");
    7 // you may not use this file except in compliance with the License.
    8 // You may obtain a copy of the License at
    9 //
   10 //     http://www.apache.org/licenses/LICENSE-2.0
   11 //
   12 // Unless required by applicable law or agreed to in writing, software
   13 // distributed under the License is distributed on an "AS IS" BASIS,
   14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   15 // See the License for the specific language governing permissions and
   16 // limitations under the License.
   17 // </copyright>
   18 
   19 using System;
   20 
   21 namespace OpenQA.Selenium
   22 {
   23     /// <summary>
   24     /// Provides a mechanism for Navigating with the driver.
   25     /// </summary>
   26     internal class Navigator : INavigation
   27     {
   28         private WebDriver driver;
   29 
   30         /// <summary>
   31         /// Initializes a new instance of the <see cref="Navigator"/> class
   32         /// </summary>
   33         /// <param name="driver">Driver in use</param>
   34         public Navigator(WebDriver driver)
   35         {
   36             this.driver = driver;
   37         }
   38 
   39         /// <summary>
   40         /// Move the browser back
   41         /// </summary>
   42         public void Back()
   43         {
   44             this.driver.InternalExecute(DriverCommand.GoBack, null);
   45         }
   46 
   47         /// <summary>
   48         /// Move the browser forward
   49         /// </summary>
   50         public void Forward()
   51         {
   52             this.driver.InternalExecute(DriverCommand.GoForward, null);
   53         }
   54 
   55         /// <summary>
   56         /// Navigate to a url for your test
   57         /// </summary>
   58         /// <param name="url">String of where you want the browser to go to</param>
   59         public void GoToUrl(string url)
   60         {
   61             this.driver.Url = url;
   62         }
   63 
   64         /// <summary>
   65         /// Navigate to a url for your test
   66         /// </summary>
   67         /// <param name="url">Uri object of where you want the browser to go to</param>
   68         public void GoToUrl(Uri url)
   69         {
   70             if (url == null)
   71             {
   72                 throw new ArgumentNullException(nameof(url), "URL cannot be null.");
   73             }
   74 
   75             this.driver.Url = url.ToString();
   76         }
   77 
   78         /// <summary>
   79         /// Refresh the browser
   80         /// </summary>
   81         public void Refresh()
   82         {
   83             // driver.SwitchTo().DefaultContent();
   84             this.driver.InternalExecute(DriverCommand.Refresh, null);
   85         }
   86     }
   87 }