我开发了一个UI测试,我运行了一个镀铬工具。 比我在Visual Studio中安装了PhantomJs,我收到了一个错误。我尝试使用XPath,并尝试使用ELement Id,PhantomJs找不到它们。
public void Vendormaintenance()
{
Driver.FindElement(By.XPath(".//*[@id='ctl00_cphPage_RadGridVendors_ctl00_ctl04_gbcEditCommandColumn']")).Click(); //edit Button
var vendorName = Driver.FindElement(By.Id("ctl00_cphPage_RadGridVendors_ctl00_ctl05_EditFormControl_txtName")).GetAttribute("Value"); //Lieferanten Name
Wait.Until(ExpectedConditions.ElementExists(By.Id("ctl00_cphPage_RadGridVendors_ctl00_ctl05_EditFormControl_lblEditVendorsHeader")));
var vendorCode = Driver.FindElement(By.Id("ctl00_cphPage_RadGridVendors_ctl00_ctl05_EditFormControl_txtCode")).GetAttribute("value"); //LieferantenCode
var textName = Driver.FindElement(By.Id("ctl00_cphPage_RadGridVendors_ctl00_ctl05_EditFormControl_txtName")); //Lieferanten Name bearbeiten
textName.Clear();
textName.SendKeys("Mc Donalds");
Thread.Sleep(TimeSpan.FromSeconds(5));
var safe = Driver.FindElement(By.Id("ctl00_cphPage_RadGridVendors_ctl00_ctl05_EditFormControl_btnUpdateEditOperands_input"));//Safe
safe.Click();
Wait.Until(
ExpectedConditions.InvisibilityOfElementLocated(
By.Id("ctl00_cphPage_RadGridVendors_ctl00_ctl05_EditFormControl_cbDocumentApproved")));
var vendorCodeField = Driver.FindElement(By.Id("ctl00_cphPage_RadGridVendors_ctl00_ctl02_ctl02_FilterTextBox_columnCode")); //Lieferanten Code Eingabefeld
vendorCodeField.SendKeys(vendorCode);
vendorCodeField.SendKeys(Keys.Return);
Wait.Until(
ExpectedConditions.InvisibilityOfElementLocated(
By.Id("ctl00_cphPage_RadGridVendors_ctl00_ctl16_gbcEditCommandColumn"))); //This is where I get this: "An exception of type 'OpenQA.Selenium.WebDriverTimeoutException' occurred in WebDriver.Support.dll but was not handled in user code"
var vendorName2 = Driver.FindElement(By.XPath(".//*[@id='ctl00_cphPage_RadGridVendors_ctl00__0']/td[5]")).Text;
Assert.AreEqual("Mc Donalds", vendorName2);
ResetVendorName(vendorName, safe, vendorName2, vendorCode);
}
有没有人能解决这个问题,或者知道它为什么不起作用?