2025-07-16 00:47:50 +01:00
|
|
|
using System;
|
|
|
|
|
using OpenQA.Selenium;
|
|
|
|
|
using OpenQA.Selenium.Chrome;
|
2026-06-14 20:05:01 +01:00
|
|
|
using OpenQA.Selenium.Firefox;
|
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
|
using yavscTests;
|
|
|
|
|
using yavscTests.ServerFixtures;
|
2025-07-16 00:47:50 +01:00
|
|
|
|
|
|
|
|
namespace SeleniumDocs.GettingStarted;
|
|
|
|
|
|
2026-06-14 20:05:01 +01:00
|
|
|
|
|
|
|
|
[Collection("Yavsc Server")]
|
|
|
|
|
public class FirstScript : BaseTestContext
|
2025-07-16 00:47:50 +01:00
|
|
|
{
|
2026-06-14 20:05:01 +01:00
|
|
|
public readonly WebServerFixture _serverFixture;
|
|
|
|
|
readonly ITestOutputHelper _output;
|
|
|
|
|
|
|
|
|
|
public FirstScript(ITestOutputHelper output, WebServerFixture fixture) : base(output, fixture)
|
|
|
|
|
{
|
|
|
|
|
_serverFixture = fixture;
|
|
|
|
|
this._output = output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void DoTestSeleniumWebSite()
|
2025-07-16 00:47:50 +01:00
|
|
|
{
|
2026-06-14 20:05:01 +01:00
|
|
|
var firefoxOptions = new FirefoxOptions();
|
|
|
|
|
firefoxOptions.AcceptInsecureCertificates = true;
|
2025-07-16 00:47:50 +01:00
|
|
|
|
2026-06-14 20:05:01 +01:00
|
|
|
var driver = new FirefoxDriver(firefoxOptions);
|
|
|
|
|
driver.Navigate().GoToUrl(_serverFixture.Addresses.FirstOrDefault(u => u.StartsWith("https:")));
|
2025-07-16 00:47:50 +01:00
|
|
|
|
|
|
|
|
var title = driver.Title;
|
|
|
|
|
|
|
|
|
|
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);
|
|
|
|
|
|
|
|
|
|
var textBox = driver.FindElement(By.Name("my-text"));
|
|
|
|
|
var submitButton = driver.FindElement(By.TagName("button"));
|
|
|
|
|
|
|
|
|
|
textBox.SendKeys("Selenium");
|
|
|
|
|
submitButton.Click();
|
|
|
|
|
|
|
|
|
|
var message = driver.FindElement(By.Id("message"));
|
|
|
|
|
var value = message.Text;
|
|
|
|
|
|
|
|
|
|
driver.Quit();
|
|
|
|
|
}
|
|
|
|
|
}
|