我們的團隊有幾個星期的問題。目前,我們在MSTest v1和Selenium 3.11中進行了一項測試,該測試專用于在填寫個人資料時上傳照片。在本地環(huán)境中工作正常(呵呵),但是在遠程環(huán)境(RemoteWebdriver)中,僅在我與該窗口進行交互的步驟中,“訪問與拒絕”類型的“構(gòu)建與發(fā)布”服務(wù)器(VSTS)會引發(fā)錯誤。不是真正的Selenium在那里起作用,而是System.Windows.Forms庫和SendKeys類的SendWait方法在遠程啟動該錯誤時給出錯誤。示例代碼:using System;using Microsoft.VisualStudio.TestTools.UnitTesting;using System.Windows.Forms;using OpenQA.Selenium;using System.IO;//...public class EditarFotoUsuarioAdministrador { public static void Execute(IWebDriver driver, string foto) { driver.FindElement(By.XPath("//button[@id='upload']")).Click(); System.Threading.Thread.Sleep(2000); SendKeys.SendWait(Directory.GetCurrentDirectory() + foto); SendKeys.SendWait(@"{Enter}"); System.Threading.Thread.Sleep(2000); driver.FindElement(By.XPath("//button[@id='save']")).Click(); System.Threading.Thread.Sleep(500); }}就像我說的那樣,這在本地可以很好地工作,但是當(dāng)它在遠程服務(wù)器上運行時,整個測試運行良好,直到到達SendKeys行:
3 回答

江戶川亂折騰
TA貢獻1851條經(jīng)驗 獲得超5個贊
AutoIT3或AutoItX.Dotnet?您可以發(fā)送代碼段嗎?我用下面的代碼
` AutoItX.WinActivate("Open");
AutoItX.ControlGetFocus("Open");
AutoItX.Send(file);
System.Threading.Thread.Sleep(2000);
AutoItX.ControlClick("Open", " ", "Button1");`
它在本地工作正常,但在遠程工作不正常
- 3 回答
- 0 關(guān)注
- 284 瀏覽
添加回答
舉報
0/150
提交
取消