"Fossies" - the Fresh Open Source Software Archive

Member "selenium-selenium-4.8.1/dotnet/test/webdriverbackedselenium/SeleniumTestCaseBase.cs" (17 Feb 2023, 1878 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 using OpenQA.Selenium;
    4 using System.Reflection;
    5 using System.IO;
    6 using Selenium.Tests.Environment;
    7 
    8 namespace Selenium.Tests
    9 {
   10     public class SeleniumTestCaseBase
   11     {
   12         protected ISelenium selenium;
   13         private string baseUrl = "http://localhost:" + EnvironmentManager.Instance.Port.ToString() + "/selenium-server";
   14         [OneTimeSetUp]
   15         public void FixtureSetUp()
   16         {
   17             //selenium = new WebDriverBackedSelenium(EnvironmentManager.Instance.StartDriver(), baseUrl + "/tests");
   18             //selenium.Start();
   19             selenium = EnvironmentManager.Instance.GetCurrentSelenium();
   20         }
   21 
   22         [OneTimeTearDown]
   23         public void FixtureTearDown()
   24         {
   25             //selenium.Stop();
   26             
   27         }
   28 
   29         [SetUp]
   30         public void SetUp()
   31         {
   32             string script = ReadSupportScript();
   33             IWebDriver driver = ((WebDriverBackedSelenium)selenium).UnderlyingWebDriver;
   34             driver.Url = baseUrl;
   35             ((IJavaScriptExecutor)driver).ExecuteScript(script);
   36         }
   37 
   38         private string ReadSupportScript()
   39         {
   40             string scriptFilePath = Path.Combine(GetExecutingDirectory(), "testHelpers.js");
   41             return File.ReadAllText(scriptFilePath);
   42         }
   43 
   44         private string GetExecutingDirectory()
   45         {
   46             Assembly executingAssembly = Assembly.GetExecutingAssembly();
   47             string assemblyLocation = executingAssembly.Location;
   48 
   49             // If we're shadow copying,. fiddle with 
   50             // the codebase instead 
   51             if (AppDomain.CurrentDomain.ShadowCopyFiles)
   52             {
   53                 Uri uri = new Uri(executingAssembly.CodeBase);
   54                 assemblyLocation = uri.LocalPath;
   55             }
   56 
   57             return Path.GetDirectoryName(assemblyLocation);
   58         }
   59     }
   60 }