私はこれが見た目よりも簡単であることを望んでいます、そして私はそれを修正しようとして雪盲になりました!あなたの助けはこれに関して大いに感謝されるでしょう。
私はPageObjectモデル(私は思う!)を使用してテストを作成しています。画像の参照とアップロードを複製するオブジェクトがあります。これを実行するには、AutoItスクリプトを呼び出す必要があります。これは機能しますが、画像をアップロードすると、ID属性があるにもかかわらず、[アップロード]ボタンが見つかりません。
ファイルの選択後に正しく有効になっているので、何が欠けているのかわからない。
PageObjectのコードは次のとおりです。
public void AddImage(string FileDescription, int DocNo, int Revision, string StatusLstItem, string CreationDate)
{
driver.FindElement(By.Id("Button1")).Click();
driver.SwitchTo().Window("FileDetails");
driver.FindElement(By.Id("Description1")).Clear();
driver.FindElement(By.Id("Description1")).SendKeys(FileDescription);
driver.FindElement(By.Id("DocNo1")).Clear();
driver.FindElement(By.Id("DocNo1")).SendKeys(DocNo.ToString());
driver.FindElement(By.Id("revision1")).Clear();
driver.FindElement(By.Id("revision1")).SendKeys(Revision.ToString());
new SelectElement(driver.FindElement(By.Id("FileStatus1"))).SelectByText(StatusLstItem);
driver.FindElement(By.Id("creationDate1")).Clear();
driver.FindElement(By.Id("creationDate1")).SendKeys(CreationDate);
IWebElement element = driver.FindElement(By.Id("Filename1"));
element.Click();
Process.Start("C:\\Users\\Tom\\Desktop\\FileUploadCr.exe");
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
IWebElement upload = driver.FindElement(By.Id("action1"));
upload.Click();
}
AddImage
次に、以下を使用して、テストクラスから''メソッドを呼び出しています。
[Test]
public void ItemChecks()
{
InformationObject informationObject = new InformationObject(driver);
informationObject.ExpandAllButton();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
informationObject.AddImage("SampleDesc", 01, 01, "Approved", "01/10/2012");
informationObject.ClickUpdateButtonOne();
}
何らかの理由で、「action1」アップロードボタンを検索/クリックしていません。「FileDetails」ウィンドウに切り替えてみましたが、これも機能しません。
私が欠けているアイデアは何ですか?
参考までに-[アップロード]ボタンのコードは次のとおりです。
<input type="Submit" value="Upload" id="action1" disabled=""/>
UPDATE-修正されて機能するPageObjectメソッドは次のようになります。
public void AddImage(string FileDescription, int DocNo, int Revision, string StatusLstItem, string CreationDate)
{
driver.FindElement(By.Id("Button1")).Click();
driver.SwitchTo().Window("FileDetails");
IWebElement element = driver.FindElement(By.Id("Filename1"));
element.Click();
Process.Start("C:\\Users\\Tom\\Documents\\Visual Studio 2010\\Projects\\AutoIt_Files\\FileUploadCr.exe");
Thread.Sleep(1000);
driver.FindElement(By.Id("Description1")).Clear();
driver.FindElement(By.Id("Description1")).SendKeys(FileDescription);
driver.FindElement(By.Id("DocNo1")).Clear();
driver.FindElement(By.Id("DocNo1")).SendKeys(DocNo.ToString());
driver.FindElement(By.Id("revision1")).Clear();
driver.FindElement(By.Id("revision1")).SendKeys(Revision.ToString());
new SelectElement(driver.FindElement(By.Id("FileStatus1"))).SelectByText(StatusLstItem);
driver.FindElement(By.Id("creationDate1")).Clear();
driver.FindElement(By.Id("creationDate1")).SendKeys(CreationDate);
driver.SwitchTo().Window("FileDetails");
Thread.Sleep(1000);
IWebElement upload = driver.FindElement(By.Id("action1"));
upload.Click();
Thread.Sleep(1000);
driver.SwitchTo().Alert().Dismiss(); //Ignore this, just an alert that displays following upload and not part of the solution
}