Exemplo 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 (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);
     }
 }
Exemplo n.º 2
0
        public void Execute(Arguments arguments)
        {
            try
            {
                SeleniumWrapper wrapper = SeleniumManager.CreateWrapper(
                    "chrome",
                    "https://accounts.google.com/signin/v2/identifier?continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&sacu=1&rip=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin",
                    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[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/div/form/span/section/div/div/div[1]/div/div[1]/div/div[1]/input";
                arguments.By.Value     = "xpath";
                SeleniumManager.CurrentWrapper.TypeText(arguments.email.Value, arguments, arguments.Timeout.Value);

                arguments.Search.Value = "/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div/div/button/div[2]";
                arguments.By.Value     = "xpath";
                SeleniumManager.CurrentWrapper.Click(arguments, arguments.Timeout.Value);

                arguments.Search.Value = "password";
                arguments.By.Value     = "name";
                SeleniumManager.CurrentWrapper.TypeText(arguments.pword.Value, arguments, arguments.Timeout.Value);

                arguments.Search.Value = "/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div/div/button/div[2]";
                arguments.By.Value     = "xpath";
                SeleniumManager.CurrentWrapper.Click(arguments, arguments.Timeout.Value);

                RobotMessageBox.Show("Enter two step process if applicable");
            }
            catch (Exception ex)
            {
                throw new ApplicationException($"Error occured while typing text to element. Text: '{arguments.email.Value}'. 'Search element phrase: '{arguments.By.Value}'.'{arguments.pword.Value}'. Message: {ex.Message}", ex);
            }
        }