我在 Android 版 Unity 上遇到错误。
我的代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using UnityCursova;
using UnityEngine.UI;
public class MainProgram : MonoBehaviour
{
[SerializeField]
public Text FirstText;
IWebDriver driver;
void Start()
{
driver = new ChromeDriver(@"Assets/Packages/Selenium.Chrome.WebDriver.85.0.0/driver/");
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
driver.Navigate().GoToUrl("https://dekanat.lnu.edu.ua/cgi-bin/classman.cgi?n=999");
}
// Update is called once per frame
void Update()
{
}
}
错误:
Win32Exception: ApplicationName='Assets/Packages/Selenium.Chrome.WebDriver.85.0.0/driver/chromedriver.exe', CommandLine='--port=49237', CurrentDirectory='', Native error= The system cannot find the file specified.
你就快到了。您只需将可执行文件的名称(即
chromedriver.exe
)添加到现有字符串 @"Assets/Packages/Selenium.Chrome.WebDriver.85.0.0/driver/"
。
实际上您的代码行将是:
driver = new ChromeDriver(@"Assets/Packages/Selenium.Chrome.WebDriver.85.0.0/driver/chromedriver.exe");
后续问题:
是否可以将其编译为单个 .APK 文件,因为它依赖于 chromedriver.EXE(通常用于桌面应用程序)?