【问题标题】:Sikuli Integrator C#Sikuli 积分器 C#
【发布时间】:2015-03-06 09:47:45
【问题描述】:

我想在 C# 中使用 SikuliIntegrator。 我以管理员身份运行 VS,通过 NuGet 管理器安装 SikuliIntegrator,并想在简单的任务上测试他。

这是我的代码

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);
        }
    }
}

运行代码后(并在屏幕上准备好 MyPicture),我得到的只是异常“###FAILURE”,知道为什么吗?

我不想使用 Sikuli4Net,因为它看起来像是在 web 应用程序上工作,我只需要在桌面应用程序上简单点击几下。

我在 Java 中尝试了 sikuli,它在那里没有问题。但我需要用 C# 编写程序。

【问题讨论】:

  • 尝试使用 cmets here ,或者在您的问题中添加一个。

标签: c# automation jython sikuli


【解决方案1】:

我在 C# 中为 Sikuli4Net 使用了此代码,它首先为我工作您需要添加参考,请参阅此链接以获取参考 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】:

    我使用了这段代码,它运行良好。首先你应该打开你要点击的网页,然后给出图片的路径(它应该是网页的一部分)

    这是我的代码:

    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】:

      要使用SikuliInyegrator,需要查看这些文件中的执行结果:

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

      你还需要:

      • 已安装 JRE7 或更高版本
      • 将环境变量 PATHbin 文件夹的位置相匹配
      • 根据您的 java JRE 运行时平台,查看安装在 x86 和 x64 位的“控制面板 > 程序和功能 > Visual C++ 2010 Redistributable Package”中。如果没有,请从 Microsoft 网站下载并安装 Redistributable Package。

      【讨论】:

        猜你喜欢
        • 2014-10-06
        • 2017-08-09
        • 1970-01-01
        • 2016-02-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-10-17
        相关资源
        最近更新 更多