public override void RunCommand(object sender)
        {
            var engine = (Core.Automation.Engine.AutomationEngineInstance)sender;

            var vInstance = v_InstanceName.ConvertToUserVariable(engine);

            var browserObject = engine.GetAppInstance(vInstance);


            var script           = v_ScriptCode.ConvertToUserVariable(sender);
            var args             = v_Args.ConvertToUserVariable(sender);
            var seleniumInstance = (OpenQA.Selenium.IWebDriver)browserObject;


            OpenQA.Selenium.IJavaScriptExecutor js = (OpenQA.Selenium.IJavaScriptExecutor)seleniumInstance;

            object result;

            if (String.IsNullOrEmpty(args))
            {
                result = js.ExecuteScript(script);
            }
            else
            {
                result = js.ExecuteScript(script, args);
            }

            //apply result to variable
            if ((result != null) && (!string.IsNullOrEmpty(v_userVariableName)))
            {
                result.ToString().StoreInUserVariable(sender, v_userVariableName);
            }
        }
Пример #2
0
        public override void RunCommand(object sender)
        {
            var engine = (Core.Automation.Engine.AutomationEngineInstance)sender;

            var vInstance = v_InstanceName.ConvertToUserVariable(engine);

            var browserObject = engine.GetAppInstance(vInstance);


            var script           = v_ScriptCode.ConvertToUserVariable(sender);
            var args             = v_Args.ConvertToUserVariable(sender);
            var seleniumInstance = (OpenQA.Selenium.IWebDriver)browserObject;


            OpenQA.Selenium.IJavaScriptExecutor js = (OpenQA.Selenium.IJavaScriptExecutor)seleniumInstance;


            if (String.IsNullOrEmpty(args))
            {
                js.ExecuteScript(script);
            }
            else
            {
                js.ExecuteScript(script, args);
            }
        }
Пример #3
0
        public News GetLasNewsFromSite(string link)
        {
            StartBrowser();
            OpenQA.Selenium.Support.UI.WebDriverWait wait =
                new OpenQA.Selenium.Support.UI.WebDriverWait(driver, System.TimeSpan.FromSeconds(120));

            wait.Until(webDriver => ((OpenQA.Selenium.IJavaScriptExecutor)webDriver)
                       .ExecuteScript("return document.readyState").Equals("complete"));
            driver.Navigate().GoToUrl(link);

            System.Threading.Thread.Sleep(5000);
            string newsHeader = driver.FindElement(OpenQA.Selenium.By
                                                   .ClassName("article__header"))
                                .FindElement(OpenQA.Selenium.By
                                             .ClassName("article__title")).Text;

            string imgLink = driver.FindElement(
                OpenQA.Selenium.By
                .ClassName("photoview__open"))
                             .FindElement(OpenQA.Selenium.By
                                          .TagName("img"))
                             .GetAttribute("src");

            var texts = driver.FindElements(OpenQA.Selenium.By
                                            .ClassName("article__text"));

            OpenQA.Selenium.IJavaScriptExecutor js =
                (OpenQA.Selenium.IJavaScriptExecutor)driver;

            var sb = new System.Text.StringBuilder();

            string shortText = texts[0].Text;

            foreach (var text in texts)
            {
                if (text != null)
                {
                    sb.Append(text.Text);
                }
                else
                {
                    sb.Append("");
                }
            }


            News news = new News()
            {
                Date       = System.DateTime.Now.ToString("yyyy-dd-dd hh:ss:ff"),
                ShortStory = Translation.Translate("en", shortText),
                FullStory  = Translation.Translate("en", sb.ToString()),
                Link       = link,
                Header     = Translation.Translate("en", newsHeader),
                ImageLink  = imgLink
            };

            return(news);
        }
Пример #4
0
        public override void Run(TestContainer container)
        {
            try
            {
                //* add for IsExecuteCommand start
                if (!base.IsCommandContinue(container))
                {
                    this.PassTest = true;
                    this.SkipTest = true;
                    return;
                }
                //* add for IsExecuteCommand end

                var jsFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, base.GetParameter("FilePath"));
                if (File.Exists(jsFilePath))
                {
                    string jsCode = File.ReadAllText(jsFilePath);

                    OpenQA.Selenium.IJavaScriptExecutor js = (OpenQA.Selenium.IJavaScriptExecutor)container.Driver;
                    string strOutput = js.ExecuteScript(jsCode).ToString();

                    this.PassTest = true;

                    //* add for output and IsExpectedFail start
                    this.Output = base.GetOutPut(this.Output.Key, this.Output, this.PassTest, true, strOutput);
                    //* add for output and IsExpectedFail end

                    //* add for output and IsExpectedFail start
                    this.PassTest = GetTestPassExpected(this.PassTest);
                    //* add for output and IsExpectedFail end

                    //*add for ScreenShot start
                    if (!this.PassTest)
                    {
                        base.CommandFailScreenShot(container);
                    }
                    //*add for ScreenShot end
                }
                else
                {
                    throw new Exception(String.Format("JS file not found in {0}", jsFilePath));
                }
            }
            catch (Exception ex)
            {
                //*add for ScreenShot start
                base.CommandFailScreenShot(container);
                //*add for ScreenShot end
                throw ex;
            }
        }
Пример #5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            ChromeOptions lehetosegek = new ChromeOptions();

            //lehetosegek.AddArgument("--headless");
            vezerlo = new ChromeDriver(lehetosegek);
            js      = (OpenQA.Selenium.IJavaScriptExecutor)vezerlo;

            vizsgalandoWebElemek = new List <OpenQA.Selenium.IWebElement>();

            vezerlo.Manage().Window.Size = new System.Drawing.Size(1280, 1024);
            vezerlo.Manage().Window.Position = new Point(0, 0);
            vezerlo.Manage().Window.Maximize();

            megadAccountErtekek();

            idozito.Start();

            idozito.Interval = 3 * 1000;
        }
Пример #6
0
        public override void Run(TestContainer container)
        {
            try
            {
                //* add for IsExecuteCommand start
                if (!base.IsCommandContinue(container))
                {
                    this.PassTest = true;
                    this.SkipTest = true;
                    return;
                }
                //* add for IsExecuteCommand end

                OpenQA.Selenium.IJavaScriptExecutor js = (OpenQA.Selenium.IJavaScriptExecutor)container.Driver;
                string strOutput = js.ExecuteScript(base.GetParameter("Statement")).ToString();

                this.PassTest = true;

                //* add for output and IsExpectedFail start
                this.Output = base.GetOutPut(this.Output.Key, this.Output, this.PassTest, true, strOutput);
                //* add for output and IsExpectedFail end

                //* add for output and IsExpectedFail start
                this.PassTest = GetTestPassExpected(this.PassTest);
                //* add for output and IsExpectedFail end

                //*add for ScreenShot start
                if (!this.PassTest)
                {
                    base.CommandFailScreenShot(container);
                }
                //*add for ScreenShot end
            }
            catch (Exception ex)
            {
                //*add for ScreenShot start
                base.CommandFailScreenShot(container);
                //*add for ScreenShot end
                throw ex;
            }
        }
Пример #7
0
        public void BotForAdminPanel(News news)
        {
            try
            {
                StartBrowser();

                driver.Navigate().GoToUrl("https://oldfor.com/admin.php?mod=addnews&action=addnews");

                System.Threading.Thread.Sleep(2000);
                driver.FindElement(OpenQA.Selenium.
                                   By.Name("username")).SendKeys("*****@*****.**");
                driver.FindElement(OpenQA.Selenium.
                                   By.Name("password")).SendKeys("orxan12345");
                driver.Manage().Window.Maximize();
                driver.FindElement(OpenQA.Selenium.
                                   By.ClassName("legitRipple")).Click();
                System.Threading.Thread.Sleep(1000);

                driver.FindElement(OpenQA.Selenium.
                                   By.Name("title")).SendKeys(news.Header);
                System.Threading.Thread.Sleep(1000);
                var divElement = driver.FindElement(OpenQA.Selenium.
                                                    By.Id("category_chosen"));

                OpenQA.Selenium.Interactions.Actions actions = new OpenQA.Selenium.Interactions.Actions(driver);

                actions.MoveToElement(divElement).Click().Perform();
                OpenQA.Selenium.IJavaScriptExecutor js = (OpenQA.Selenium.IJavaScriptExecutor)driver;
                System.Threading.Thread.Sleep(1000);

                var item = driver.FindElement(OpenQA.Selenium.By
                                              .CssSelector(".chosen-results > li:nth-child(2)"));
                actions.MoveToElement(item).Click().Perform();

                driver.SwitchTo().DefaultContent();

                System.Threading.Thread.Sleep(2000);

                driver.FindElement(OpenQA.Selenium.
                                   By.Id("mceu_7-button")).Click();
                var mediaUploadFrame = driver.FindElement(OpenQA.Selenium.By
                                                          .CssSelector("#mediauploadframe"));
                driver.SwitchTo().Frame(mediaUploadFrame);
                System.Threading.Thread.Sleep(3000);

                driver.FindElement(OpenQA.Selenium.
                                   By.XPath("//button[.='Select All']")).Click();

                System.Threading.Thread.Sleep(2000);

                driver.FindElement(OpenQA.Selenium.
                                   By.XPath("//button[.='Delete files']")).Click();
                driver.SwitchTo().DefaultContent();
                System.Threading.Thread.Sleep(1000);

                driver.FindElement(OpenQA.Selenium.
                                   By.XPath("//button[.='Yes']")).Click();
                System.Threading.Thread.Sleep(2000);

                driver.SwitchTo().Frame(mediaUploadFrame);
                System.Threading.Thread.Sleep(1000);

                driver.FindElement(OpenQA.Selenium.
                                   By.Id("copyurl")).SendKeys(news.ImageLink);

                System.Threading.Thread.Sleep(2000);

                driver.FindElement(OpenQA.Selenium.
                                   By.XPath("//button[@class='edit' and contains(@onclick,'upload_from_url')]")).Click();

                System.Threading.Thread.Sleep(5000);

                driver.FindElement(OpenQA.Selenium.
                                   By.XPath("//button[.='Select All']")).Click();
                System.Threading.Thread.Sleep(2000);

                driver.FindElement(OpenQA.Selenium.
                                   By.XPath("//button[.='Insert selected']")).Click();
                driver.SwitchTo().DefaultContent();
                System.Threading.Thread.Sleep(2000);
                var editorFrame = driver.FindElement(OpenQA.Selenium.By.CssSelector("#short_story_ifr"));
                driver.SwitchTo().Frame(editorFrame);

                driver.FindElement(OpenQA.Selenium.
                                   By.XPath("//*[@data-id='short_story']")).FindElement(OpenQA.Selenium.
                                                                                        By.TagName("p")).SendKeys(news.ShortStory);
                System.Threading.Thread.Sleep(2000);

                driver.SwitchTo().DefaultContent();
                System.Threading.Thread.Sleep(1000);
                driver.SwitchTo().DefaultContent();
                driver.FindElement(OpenQA.Selenium.
                                   By.Id("mceu_75-button")).Click();

                var editorFrame2 = driver.FindElement(OpenQA.Selenium.
                                                      By.Id("full_story_ifr"));
                driver.SwitchTo().Frame(editorFrame2);
                System.Threading.Thread.Sleep(1000);

                driver.FindElement(OpenQA.Selenium.
                                   By.XPath("//*[@data-id='full_story']")).FindElement(OpenQA.Selenium.
                                                                                       By.TagName("p")).SendKeys(news.FullStory);
                System.Threading.Thread.Sleep(2000);

                driver.SwitchTo().DefaultContent();
                System.Threading.Thread.Sleep(2000);
                var mediaUploadFrame2 = driver.FindElement(OpenQA.Selenium.By.Name("mediauploadframe"));
                driver.SwitchTo().Frame(mediaUploadFrame2);
                driver.FindElement(OpenQA.Selenium.
                                   By.XPath("//button[.='Select All']")).Click();
                System.Threading.Thread.Sleep(2000);

                driver.FindElement(OpenQA.Selenium.
                                   By.XPath("//button[.='Insert selected']")).Click();
                System.Threading.Thread.Sleep(2000);
                driver.SwitchTo().DefaultContent();
                System.Threading.Thread.Sleep(1000);
                driver.FindElement(OpenQA.Selenium.
                                   By.Id("addnews")).Submit();
            }
            catch (System.TimeoutException e)
            {
                System.Console.WriteLine("Driver timeoout exception occured -- " + e);
            }
            catch (System.Exception e)
            {
                System.Console.WriteLine("another exception occured -- " + e);
            }
        }