Sikuli Integrator C#

a 夏天 提交于 2019-12-20 05:44:10

问题


I want to use SikuliIntegrator in C#. I run VS as administrator, install SikuliIntegrator throught NuGet manager and want to test him on simple task.

Heres my code

using SikuliModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SikuliTrainingNet
{
    class Program
    {
        static void Main(string[] args)
        {
            string MyPicture = @"c:\111\Sik\MyPicture.png";
            SikuliAction.Click(MyPicture);
        }
    }
}

after running code (and have prepared MyPicture on screen), all i get is exception "###FAILURE" any idea why?

I dont wanna use Sikuli4Net, becose its look like it work on web aps and I need just few simple clicks on desktop aplication.

I try sikuli in Java, and there it works with no problem. But I need to make my program in C#.


回答1:


I Used This Code For Sikuli4Net in C#,It Was Working For Me First You need add the References please see this link for Reference http://interviews.ga/angularjs/sikulic/

static void Main(string[] args)
        {
            APILauncher launch = new APILauncher(true);

            Pattern image1 = new Pattern(@"C:\Users\Ramesh\Desktop\Images\userName.png");
            Pattern image2 = new Pattern(@"C:\Users\Ramesh\Desktop\Images\password.png");
            Pattern image3 = new Pattern(@"C:\Users\Ramesh\Desktop\Images\Login.png");

            launch.Start();

            IWebDriver driver = new ChromeDriver();

            driver.Manage().Window.Maximize();

            driver.Url = "http://gmail.com";

            Screen scr = new Screen();

            scr.Type(image1, "abc@gmail.com", KeyModifier.NONE);

            scr.Type(image2, "12345", KeyModifier.NONE);

            scr.Click(image3, true);

            Console.ReadLine();
        }



回答2:


I used this code and it was working fine. First you should open the webpage on which you want to click and then give a path of the image(it should be a part of the webpage)

here is my code:

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SikuliModule;
using OpenQA.Selenium;

namespace WordPressAutomation.DifferentTests
{
    [TestClass]
public class Sikuli
{
    [TestMethod]
    public void TestMethod1()
    {
        driver.Initialize();
        driver.instance.Navigate().GoToUrl("https://www.google.co.in");
        SikuliAction.Click("E:/img.png");
    }
}
}



回答3:


To use SikuliInyegrator, you need to check the execution results in these files:

C:\SikuliExceptionLog.txt
C:\SikuliOutputLog.txt

Also you need to:

  • Have installed JRE7 or superior
  • Have environment variable PATH with the location of the bin folder
  • See installed in your “control panel > program and features> visual C++ 2010 Redistributable Package” at x86 and x64 bits according to your java JRE runtime platform. If not, then download and install the Redistributable Package form Microsoft site.


来源:https://stackoverflow.com/questions/27837423/sikuli-integrator-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!