【问题标题】:Getting an Exception System.ComponentModel.Win32Exception : The system cannot find the file specified in Sikuli C#获取异常 System.ComponentModel.Win32Exception : 系统找不到 Sikuli C# 中指定的文件
【发布时间】:2018-09-26 23:04:46
【问题描述】:

我收到异常 System.ComponentModel.Win32Exception:当我在 C# 中使用 Selenium 使用 Sikuli 时,系统找不到指定的文件。

我已经参考了 Stack 中的其他帖子,但我还没有找到解决方案。 我也在管理员模式下运行 VS 2017 我在 /Debug 文件夹中有最新的 Rest-Api Jar 副本。

下面是我的代码

using System;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Support.UI;
using Sikuli4Net.sikuli_REST;
using Sikuli4Net.sikuli_UTIL;
using SikuliModule;

namespace DownloadFile
{
public class Download
{
    private IWebDriver driver;
    private APILauncher launcher;
    [SetUp]

    public void setup()
    {
        driver = new FirefoxDriver();
        launcher = new APILauncher(true);
        driver.Navigate().GoToUrl("https://java.com/en/download/");
        driver.Manage().Window.Maximize();
    }

    [Test]
    public void TestMethod1()
    {
        new WebDriverWait(driver, TimeSpan.FromSeconds(60)).Until(ExpectedConditions.ElementExists((By.XPath("//span[contains(text(),'Free Java Download')]")))).Click();
        new WebDriverWait(driver, TimeSpan.FromSeconds(60)).Until(ExpectedConditions.ElementExists((By.XPath("//span[contains(text(),'Agree and Start Free Download')]")))).Click();
        launcher.Start();
        Screen screen = new Screen();
        Pattern Click_Save = new Pattern("C:/Selenium Files/Save.jpg");
        screen.Wait(Click_Save, 500);
        screen.Click(Click_Save);
        launcher.Stop();


    }
}

}

【问题讨论】:

    标签: c# selenium sikuli selenium-firefoxdriver


    【解决方案1】:

    在下面的代码行中更新 .jpg 文件的路径:

        Pattern Click_Save = new Pattern("C:\\Selenium Files\\Save.jpg");
    

    其余的代码看起来没问题。

    【讨论】:

    • 还是同样的问题。我什至更改了文件夹结构。
    猜你喜欢
    • 2019-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多