--------- common method page ................................................
using Microsoft.VisualStudio.TestTools.UITest.Extension;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace Dell.SVL.NexusCore
{
public static class Browserwindow
{
public static
BrowserWindow browserWindow;
public static void LaunchApplication(string appUrl, string bType = "IExplorer", bool clearData = true )
{
try
{
browserWindow =
BrowserWindow.Launch();
if (clearData)
{
BrowserWindow.ClearCache();
BrowserWindow.ClearCookies();
}
browserWindow.NavigateToUrl(new Uri(appUrl));
browserWindow.Maximized = true;
}
catch (Exception Ex)
{
//Console.WriteLine("Browser
doesn't launched successfully");
Assert.Fail(Ex.Message);
}
}
public static void InitializePlayBackSettings()
{
try
{
if (!Playback.IsInitialized)
{
Playback.Initialize();
}
Playback.PlaybackSettings.SmartMatchOptions
= SmartMatchOptions.None;
Playback.PlaybackSettings.AlwaysSearchControls = true;
Playback.PlaybackSettings.MatchExactHierarchy = true;
Playback.PlaybackSettings.WaitForReadyLevel
= WaitForReadyLevel.UIThreadOnly;
Playback.PlaybackSettings.MaximumRetryCount = 4;
Playback.PlaybackSettings.SearchTimeout = 30000;
}
catch(Exception Ex)
{
Assert.Fail(Ex.Message);
}
}
public static void ResetPlayBackSettings()
{
try
{
if (Playback.IsInitialized)
{
Playback.StopSession();
Playback.Cleanup();
}
}
catch (Exception Ex)
{
Assert.Fail(Ex.Message);
}
}
public static void BrowserRefresh()
{
try
{
browserWindow.Refresh();
}
catch(Exception Ex)
{
Assert.Fail(Ex.Message);
}
}
}
}
[TestInitialize]
public void
BeforeAll()
{
try
{
appUrl =
testContextInstance.Properties["NexusUrl"].ToString();
GenericMethods.KillProcessByName();
Browserwindow.InitializePlayBackSettings();
actions = new Actions();
Browserwindow.LaunchApplication(appUrl);
}
catch (Exception Ex)
{
Assert.Fail(Ex.Message);
}
}
TestCleanUp
[TestCleanup]
public void
AfterAll()
{
try
{
Browserwindow.ResetPlayBackSettings();
actions = null;
GenericMethods.KillProcessByName();
GenericMethods.FreeUpMemory();
}
catch (Exception Ex)
{
Assert.Fail(Ex.Message);
}
}
No comments:
Post a Comment