﻿using OpenQA.Selenium;
using Sharpenium.Core;

namespace Sharpenium.Commands
{
    /// <summary>
    /// Instruction to click the element targetted by the selector
    /// </summary>
    public class ClickInstruction : InstructionWithElementSelector
    {
        public ClickInstruction(string name, Selector selector)
            : base(name, selector)
        {

        }

        public override void Execute(SharpeniumRunner runner, IWebDriver driver, Core.ExecutionContext executionContext)
        {
            var element = driver.FindElement(Selector.PathToByConverter());
            if (element == null)
            {

            }

            element.Click();
        }

        internal ClickInstruction()
        {
            
        }

    }
}
