Ejemplo n.º 1
0
 public void Execute(Arguments arguments)
 {
     try
     {
         SeleniumWrapper wrapper = SeleniumManager.CreateWrapper(
             arguments.Type.Value,
             arguments.Url?.Value,
             arguments.Timeout.Value,
             arguments.NoWait.Value,
             Scripter.Log,
             Scripter.Settings.UserDocsAddonFolder.FullName);
         int wrapperId = wrapper.Id;
         OnScriptEnd = () =>
         {
             SeleniumManager.DisposeAllOpenedDrivers();
             SeleniumManager.RemoveWrapper(wrapperId);
             SeleniumManager.CleanUp();
         };
         Scripter.Variables.SetVariableValue(arguments.Result.Value, new IntegerStructure(wrapper.Id));
     }
     catch (OpenQA.Selenium.DriverServiceNotFoundException ex)
     {
         throw new ApplicationException("Driver not found", ex);
     }
     catch (Exception ex)
     {
         throw new ApplicationException($"Error occured while opening new selenium instance. Url '{arguments.Url.Value}'. Message: {ex.Message}", ex);
     }
 }
Ejemplo n.º 2
0
        public void Execute(Arguments arguments)
        {
            try
            {
                SeleniumWrapper wrapper = SeleniumManager.CreateWrapper(
                    "chrome",
                    "twitter.com",
                    arguments.Timeout.Value,
                    false,
                    Scripter.Log,
                    Scripter.Settings.UserDocsAddonFolder.FullName);
                int wrapperId = wrapper.Id;
                OnScriptEnd = () =>
                {
                    SeleniumManager.DisposeAllOpenedDrivers();
                    SeleniumManager.RemoveWrapper(wrapperId);
                    SeleniumManager.CleanUp();
                };
                arguments.Search.Value = "/html/body/div/div/div/div[2]/header/div[2]/div[1]/div/div[2]/div[1]/div[1]/a";
                arguments.By.Value     = "xpath";
                SeleniumManager.CurrentWrapper.Click(arguments, arguments.Timeout.Value);
                arguments.Search.Value = "/html/body/div/div/div/div[2]/main/div/div/form/div/div[1]/label/div/div[2]/div/input";
                arguments.By.Value     = "xpath";
                SeleniumManager.CurrentWrapper.TypeText(arguments.email.Value, arguments, arguments.Timeout.Value);
                arguments.Search.Value = "/html/body/div/div/div/div[2]/main/div/div/form/div/div[2]/label/div/div[2]/div/input";
                arguments.By.Value     = "xpath";
                SeleniumManager.CurrentWrapper.TypeText(arguments.pword.Value, arguments, arguments.Timeout.Value);
                SeleniumManager.CurrentWrapper.PressKey("enter", arguments, arguments.Timeout.Value);
            }

            catch (Exception ex)
            {
                throw new ApplicationException($"Error occured while opening new selenium instance. Message: {ex.Message}", ex);
            }
        }