コード例 #1
0
        public override void Execute()
        {
            if (CheckIfImageValid())
            {
                string      logMessage     = string.Empty;
                APILauncher sikuliLauncher = new APILauncher(out logMessage, ShowSikuliConsole);
                sikuliLauncher.EvtLogMessage += sikuliLauncher_EvtLogMessage;
                sikuliLauncher.Start();

                try
                {
                    Screen sekuliScreen = new Screen();

                    Pattern sikuliPattern = new Pattern(amdocs.ginger.GingerCoreNET.WorkSpace.Instance.Solution.SolutionOperations.ConvertSolutionRelativePath(PatternPath));

                    System.Threading.Tasks.Task.Run(() => SetFocusToSelectedApplicationInstance());

                    switch (ActSikuliOperation)
                    {
                    case eActSikuliOperation.Click:
                        sekuliScreen.Click(sikuliPattern);
                        break;

                    case eActSikuliOperation.SetValue:
                        sekuliScreen.Type(sikuliPattern, SetTextValue);
                        break;

                    case eActSikuliOperation.DoubleClick:
                        sekuliScreen.DoubleClick(sikuliPattern);
                        break;

                    case eActSikuliOperation.MouseRightClick:
                        sekuliScreen.RightClick(sikuliPattern);
                        break;

                    case eActSikuliOperation.Exist:
                        sekuliScreen.Exists(sikuliPattern);
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Reporter.ToLog(eLogLevel.ERROR, ex.Message + Environment.NewLine + ex.Source, ex);
                    Error = string.Format("Error Occured while executing Sikuli Operation {0} : {1}", ActSikuliOperation, ex.Message);
                }
                finally
                {
                    sikuliLauncher.Stop();
                }
            }
        }
コード例 #2
0
        public static void SikuliType(String ImagePath, String text)
        {
            APILauncher Launch = new APILauncher(true);

            Launch.Start();
            Pattern Image = new Pattern(@ImagePath);
            Screen  scr   = new Screen();

            scr.Wait(Image, 5);
            scr.Type(Image, text, KeyModifier.NONE);
            Launch.Stop();
        }
コード例 #3
0
        public static void SikuliClick(String ImagePath)
        {
            APILauncher Launch = new APILauncher(true);
            Pattern     Image  = new Pattern(@ImagePath);

            Launch.Start();
            Screen scr = new Screen();

            scr.Wait(Image, 5);
            scr.Click(Image, true);
            Launch.Stop();
        }
コード例 #4
0
        public void Chrome_TearDown(IWebDriver driver, ILog log)
        {
            try
            {
                if (driver != null)
                {
                    Thread.Sleep(5000);
                }
                driver.Quit();

                if (recordEvidence == "yes")
                {
                    this.job.Stop();

                    this.job = null;
                }

                log.Info("Test Completed" + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                log.Info("\n \n --------------------------------------------------------------------------------------------------------------------------------");
            }
            catch (Exception e)
            {
                log.Error(e.Message + "\n" + e.StackTrace + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                log.Info("\n \n --------------------------------------------------------------------------------------------------------------------------------");

                this.job.Stop();

                Assert.AreEqual(true, false);
            }

            try
            {
                // This is to check if Sikuli setting is set to 'Yes' and then stop the launcher

                if (globList.ElementAt(0).ToString().ToLower().Equals("yes"))
                {
                    launcher.Stop();
                }
            }
            catch (Exception e)
            {
                Process[] proc = Process.GetProcessesByName("javaw");

                proc[0].Kill();

                log.Info("Javaw process killed");
            }
        }
コード例 #5
0
        public static void ClickOnImage(String path)
        {
            APILauncher launcher = new APILauncher(true);

            launcher.Start();
            Screen sc = new Screen();

            Thread.Sleep(2000);
            //Pattern pattern = new Pattern(@"D:\sk\image1.PNG");
            Pattern pattern = new Pattern(path);

            sc.Click(pattern);
            Thread.Sleep(2000);
            launcher.Stop();
        }
コード例 #6
0
        public void GoogleSearchTest()
        {
            launcher.Start();
            GetWebDriver("https://www.google.com/");

            Screen  screen               = new Screen();
            Pattern pattern_SearchText   = new Pattern(@"c:\users\stefani\documents\visual studio 2017\Projects\SeleniumAndSikuli\SeleniumAndSikuli\Images\SearchText.PNG");
            Pattern pattern_SearchButton = new Pattern(@"c:\users\stefani\documents\visual studio 2017\Projects\SeleniumAndSikuli\SeleniumAndSikuli\Images\SearchButton.PNG");
            Pattern pattern_GoogleIcon   = new Pattern(@"c:\users\stefani\documents\visual studio 2017\Projects\SeleniumAndSikuli\SeleniumAndSikuli\Images\Google.PNG");

            screen.Wait(pattern_SearchText, 250);
            screen.Type(pattern_SearchText, "Test", KeyModifier.NONE);
            screen.Wait(pattern_GoogleIcon, 200);
            screen.Click(pattern_GoogleIcon);

            screen.Wait(pattern_SearchButton, 200);
            screen.Click(pattern_SearchButton);

            Thread.Sleep(200);
            webDriver.Quit();

            launcher.Stop();
        }
コード例 #7
0
        public static void ClickOnCiscoIpPhone(Screen scr, string element)
        {
            try
            {
                //ADD PATH ENV

                APILauncher launcher = new APILauncher();
                launcher.Start();
                Screen  s  = new Screen();
                Pattern ee = new Pattern(@"D:\CiscoIpPhone\ICON_TASKBAR.png");
                s.Click(ee);

                launcher.Stop();

                //scr.Click(new Pattern(CiscoIPCommunicatorImages + element + ".png"), true);
                Thread.Sleep(1000);
            }
            catch (NotFoundException ex)
            {
                Console.WriteLine("Element does NOT exist or click able : " + element);
                Console.WriteLine("Class SikuliCiscoIpPhone | Method ClickOnCiscoIpPhone | Exception desc : " + ex.Message);
            }
        }
コード例 #8
0
        public static void ClassCleanup()
        {
            _webDriver.Quit();

            _launcher.Stop();
        }
コード例 #9
0
 public static void RunAfterAnyTests()
 {
     launcher.Stop();
 }
コード例 #10
0
        public static void Main()
        {
            APILauncher launcher = new APILauncher(true);

            launcher.Start();

            System.Net.ServicePointManager.Expect100Continue = false;
            Page   page = new Page();
            Screen scr  = new Screen();

            while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
            {
                Connecton.DeleteUser("delete from Invalid where ID_User=Invalid;");

                try
                {
                    System.Diagnostics.Process.Start(page.ISExe);

                    scr.Wait(page.DB, 100);
                    scr.Type(page.Username, "Invalid");
                    scr.Type(page.Password, "Invalid");
                    scr.Click(page.Login);
                    scr.Wait(page.TabProfireal, 100);
                    scr.Click(page.LoanButton);
                    scr.Click(page.TabLoanButton);

                    Stopwatch swt = new Stopwatch();
                    swt.Start();

                    scr.Type(page.Search, "5006010315" + Key.ENTER);
                    scr.Wait(page.Paid, 100);
                    scr.Click(page.Redaction);
                    scr.Wait(page.Request, 100);

                    swt.Stop();

                    scr.Click(page.RequestExit);
                    scr.Click(page.LoanExit);
                    scr.Click(page.ISExit);
                    scr.Wait(page.WaitQuit, 100);
                    scr.Click(page.Quit);

                    var    time    = swt.Elapsed;
                    string count   = Connecton.GetCountBySql("SELECT COUNT(*) FROM Invalid;");
                    string message = string.Format("{0};{1};{2}", DateTime.Now.ToString(), time.ToString(), count);

                    if (File.Exists(page.LogPath))
                    {
                        SaveLog(page.LogPath, message);
                    }
                    else
                    {
                        using (StreamWriter sw = File.CreateText(page.LogPath))
                        {
                            sw.WriteLine(string.Format("Date;Time;Sessions\n{0}", message));
                        }
                    }

                    if ((int)(time.TotalSeconds) > 45)
                    {
                        string body = string.Format("IS report:{0}", time.ToString());
                        EmailSend(page.LogPath, body);
                    }

                    Wait();
                }
                catch (Exception ex)
                {
                    string body = "Error:" + "\t" + ex.ToString() + "\t" + ex.StackTrace;
                    EmailSend(page.LogPath, body);
                }
            }

            launcher.Stop();
        }
コード例 #11
0
 public void MyTestCleanup()
 {
     _driver.Quit();
     _launcher.Stop();
 }
コード例 #12
0
        public static void TestTearDown()
        {
            _webDriver.Quit();

            _launcher.Stop();
        }
コード例 #13
0
 public void ClassCleanup()
 {
     driver.Quit();
     launcher.Stop();
 }
コード例 #14
0
ファイル: UnitTest1.cs プロジェクト: Hari7Kotha/Sikuli
        public void CreateFence()
        {
            luncher.Start();

            GetIWebDriver("https://dev.alexswift.com/Account/Login");

            Screen scr = new Screen();

            //Create a Pattern for "Username" field
            Pattern Username = new Pattern(@"C:\Users\chand\Desktop\SikuliTry\SikuliPattens\UserName.PNG");

            //Waiting for the pattern to appear
            scr.Wait(Username, 500);
            //SendKeys into Username field
            scr.Type(Username, "*****@*****.**", KeyModifier.NONE);

            //Create a pattern for "Password" field
            Pattern Password = new Pattern(@"C:\Users\chand\Desktop\SikuliTry\SikuliPattens\Password.PNG");

            //Wait for the pattern to appear
            scr.Wait(Password, 500);
            //SendKeys into Password field
            scr.Type(Password, "Test_123", KeyModifier.NONE);

            //Pattern to click on Login btn
            Pattern LoginBtn = new Pattern(@"C:\Users\chand\Desktop\SikuliTry\SikuliPattens\LoginBtn.PNG");

            //Wait for Pattern
            scr.Wait(LoginBtn, 500);
            //Click on Login button
            scr.Click(LoginBtn);
            Console.WriteLine("Login successfull");

            //Click on Geofence Hyperlink
            Pattern Geolink = new Pattern(@"C:\Users\chand\Desktop\SikuliTry\SikuliPattens\GeofenceLink.PNG");

            //Wait for Pattern
            scr.Wait(Geolink, 500);
            //Click on the link
            scr.Click(Geolink);
            Console.WriteLine("Clicked on the Geofence link");

            //Click on AddFence button
            Pattern AddFence = new Pattern(@"C:\Users\chand\Desktop\SikuliTry\SikuliPattens\AddFence.PNG");

            //Wait for Pattern
            scr.Wait(AddFence, 900);
            scr.RightClick(AddFence);
            //Click on AddFence button
            scr.Click(AddFence);

            ////Click on Search button
            //Pattern SearchBtn = new Pattern(@"C:\Users\chand\Desktop\SikuliTry\SikuliPattens\SearchBtn.PNG");
            ////Wait for Pattern
            //scr.Wait(SearchBtn, 800);
            ////Click on AddFence button
            //scr.Type(SearchBtn,"Auckland,Newzealand",KeyModifier.NONE);



            //Click on Navigate button to draw a fence
            //wait for pattern
            Pattern Navigate = new Pattern(@"C:\Users\chand\Desktop\SikuliTry\SikuliPattens\Navigate.PNG");

            scr.Wait(Navigate, 500);
            //Click on Square button
            scr.Click(Navigate);
            // Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Info, "Clicked on the Square button");


            //Click on Square button to draw a fence
            Pattern SquareBtn = new Pattern(@"C:\Users\chand\Desktop\SikuliTry\SikuliPattens\DrawTool.PNG");

            //wait for pattern
            scr.Wait(SquareBtn, 500);
            //Click on Square button
            scr.Click(SquareBtn);

            //Maximise the window
            Pattern Maximise = new Pattern(@"C:\Users\chand\Desktop\SikuliTry\SikuliPattens\maximise.PNG");

            //wait for pattern
            scr.Wait(Maximise, 500);
            //Click on Square button
            scr.Click(Maximise);

            //Draw a Fence
            Pattern Source = new Pattern(@"C:\Users\chand\Desktop\SikuliTry\SikuliPattens\Source.PNG");
            //wait for pattern
            //scr.Wait(Source, 500);
            Pattern Destination = new Pattern(@"C:\Users\chand\Desktop\SikuliTry\SikuliPattens\Destination.PNG");

            //wait for pattern
            //scr.Wait(Destination, 500);

            //Creating Fence by DragDrop operation
            //scr.Exists(Source, 500);
            //Region reg = new Screen();
            //Pattern p = new Pattern("someImage.png");
            //Match m = reg.find(p);
            scr.DragDrop(Source, Destination);

            Pattern minimise = new Pattern(@"C:\Users\chand\Desktop\SikuliTry\SikuliPattens\minimise.PNG");

            scr.Click(minimise);


            //Click on Save Button
            Pattern SaveBtn = new Pattern(@"C:\Users\chand\Desktop\SikuliTry\SikuliPattens\SaveBtn.PNG");

            //Wait for the pattern
            scr.Wait(SaveBtn, 500);
            //Click on Save Button
            scr.Click(SaveBtn);

            //Click on confirmation Ok button
            Pattern ConfirmOK = new Pattern(@"C:\Users\chand\Desktop\SikuliTry\SikuliPattens\ConfirmationOK.PNG");

            //Wait for pattern
            scr.Wait(ConfirmOK, 800);
            //Click on OK Button
            scr.Click(ConfirmOK);
            Console.WriteLine("Created the fence successfully");

            driver.Close();

            luncher.Stop();
        }
コード例 #15
0
        public void Web_Home_Validar_Icono_Carro_Compra()
        {
            ElementoWebHomeBT paginaBT = new ElementoWebHomeBT();

            IJavaScriptExecutor js = PropiedadColeccionDriver.driver as IJavaScriptExecutor;

            APILauncher launcher = new APILauncher(true);

            Screen screen = new Screen();

            Pattern patter_buttoncath = new Pattern("C:/Users/amoreno/Desktop/screen/buttoncath.PNG");

            string lugar = "Casa";

            string direccion = "Casa #213213 asdasd";

            string region = "(XV) Región de Arica y Parinacota";

            string comuna = "Arica";

            System.Threading.Thread.Sleep(6000);

            System.Threading.Thread.Sleep(3000);

            js.ExecuteScript("window.scrollBy(0,650);");

            System.Threading.Thread.Sleep(3000);

            paginaBT.IngresarBotónAgregarCarroProducto();

            System.Threading.Thread.Sleep(3000);

            js.ExecuteScript("window.scrollBy(0,650);");

            System.Threading.Thread.Sleep(3000);

            paginaBT.completarDirección(lugar, direccion, region, comuna);

            System.Threading.Thread.Sleep(3000);

            try
            {
                launcher.Start();

                screen.Click(patter_buttoncath);

                System.Threading.Thread.Sleep(3000);

                paginaBT.IngresarBtnContinuar();

                System.Threading.Thread.Sleep(3000);

                launcher.Stop();
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
            }


            PropiedadColeccionDriver.driver.Quit();
        }