sendkeys를 사용하여 파일을 업로드하고 있는데 어떤 이유로 인해 매우 일치하지 않습니다. 파일을 업로드하는 두 가지 시나리오가 있습니다 (기본 창에 파일 첨부 후 두 번째 창에 파일 첨부). 두 번째 창에 파일을 첨부하지 않고 주 창에 파일을 첨부하는 첫 번째 시나리오를 사용하면 완벽하게 작동합니다. 두 번째 창에서도 동일한 작업을 수행했지만 정상적으로 작동하지만 둘 다 실행하면 sendkey가 정확한 문자열을 입력하지 않습니다.Sendkeys가 selenium webdriver에서 일치하지 않습니다.
AttachFileTA.cs :
IWebElement fileAttachTA = driver.FindElement(By.XPath("//object[@class='ruObject']"));
fileAttachTA.Click();
//Switch into the windows upload dialog
Thread.Sleep(1000);
SendKeys.SendWait(file);
Thread.Sleep(1000);
SendKeys.SendWait(@"{Enter}");
Thread.Sleep(1000);
SendKeys.Flush();
Main.cs :
createDraftTA.FillGeneralInfo("This is a fourth positive test created from Selenium Webdriver");
addPrepaid.AddPrePaid("test", "Comment");
AddPrepaid.cs : 여기에 코드입니다
commentsBox.SendKeys("COMMENT");
CreateTANonProxy_Domestic attachFile = new CreateTANonProxy_Domestic(driver);
attachFile.AttachFileTA("\\Users\\My Documents\\file.txt");
FillGeneralInfo.cs는
purposeBox.SendKeys(purpose);
AttachFileTA("\\Users\\My Documents\\file.txt");
파일을 업로드하는 가장 좋은 방법은 무엇입니까? 당신이 여기 SendKeys
을 오해처럼
감사
모든