﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Support.UI;
using System;

namespace Selenium.Tests
{
    [TestClass]
    public class UnitTest1Edge : UnitTest1
    {
        /// <summary>
        /// ウェブドライバ.
        /// </summary>
        static IWebDriver _iwd;

        /// <summary>
        /// 待機用
        /// </summary>
        static WebDriverWait _wait;

        public override IWebDriver iwd => _iwd;
        public override WebDriverWait wait => _wait;

        /// <summary>
        /// クリックする.
        /// </summary>
        /// <param name="iwe"></param>
        public override void Click(IWebElement iwe)
        {
            Actions action = new Actions(iwd);
            action.MoveToElement(iwe)
                .Click()
                .Perform();
        }

        /// <summary>
        /// テストの前準備
        /// </summary>
        [ClassInitialize]
        public static void ClassInitialize(TestContext testContext)
        {
            UnitTest1.ClassInitialize();
            EdgeOptions options = new EdgeOptions();
            options.PageLoadStrategy = EdgePageLoadStrategy.Eager;
            _iwd = new EdgeDriver();
            _wait = new WebDriverWait(_iwd, new TimeSpan(0, 0, 10));
        }

        /// <summary>
        /// テストの後始末
        /// </summary>
        [ClassCleanup]
        public static new void ClassCleanup()
        {
            _iwd.Dispose();
            UnitTest1.ClassCleanup();
        }
    }
}
