Created
September 30, 2020 14:05
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
using System.Reflection; | |
using System.Diagnostics; | |
using OpenQA.Selenium; | |
using OpenQA.Selenium.Remote; | |
using System.Threading; | |
using System.Collections.Generic; | |
using NUnit.Framework; | |
using OpenQA.Selenium.Chrome; | |
using OpenQA.Selenium.Firefox; | |
using FluentAssertions; | |
namespace ParallelLTSelenium | |
{ | |
[TestFixture] | |
public class ParallelLTTests | |
{ | |
IWebDriver driver; | |
[Test] | |
public void test_locale_firefox() | |
{ | |
String username = "user-name"; | |
String accesskey = "access-key"; | |
String gridURL = "@hub.lambdatest.com/wd/hub"; | |
DesiredCapabilities capabilities = new DesiredCapabilities(); | |
var firefoxOptions = new FirefoxOptions(); | |
firefoxOptions.SetPreference("intl.accept_languages", "ja-JP"); | |
firefoxOptions.AddAdditionalCapability("user", username, true); | |
firefoxOptions.AddAdditionalCapability("accesskey", accesskey, true); | |
firefoxOptions.AddAdditionalCapability("build", "[C#] Locale Testing with Firefox & macOS on LambdaTest Selenium Grid", true); | |
firefoxOptions.AddAdditionalCapability("name", "[C#] Locale Testing with Firefox & macOS on LambdaTest Selenium Grid", true); | |
firefoxOptions.AddAdditionalCapability("version", "78.0", true); | |
firefoxOptions.AddAdditionalCapability("platform", "macOS Mojave", true); | |
driver = new RemoteWebDriver(new Uri("https://" + username + ":" + accesskey + gridURL), firefoxOptions.ToCapabilities(), TimeSpan.FromSeconds(600)); | |
//driver = new ChromeDriver(chromeOptions); | |
System.Threading.Thread.Sleep(2000); | |
driver.Url = "https://manytools.org/http-html-text/browser-language/"; | |
var executor = (IJavaScriptExecutor)driver; | |
String language = executor.ExecuteScript("return window.navigator.userlanguage || window.navigator.language").ToString(); | |
language.Should().Be("ja-JP"); | |
/* Perform wait to check the output */ | |
System.Threading.Thread.Sleep(2000); | |
} | |
[TearDown] | |
public void Cleanup() | |
{ | |
bool passed = TestContext.CurrentContext.Result.Outcome.Status == NUnit.Framework.Interfaces.TestStatus.Passed; | |
try | |
{ | |
//Logs the result to Lambdatest | |
((IJavaScriptExecutor)driver).ExecuteScript("lambda-status=" + (passed ? "passed" : "failed")); | |
} | |
finally | |
{ | |
// Terminates the remote webdriver session | |
driver.Quit(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment