Selenium webdriver Skript fehlschlägt, suchen-Taste auch mit der ID

Ich hoffe, dies ist einfacher als es scheint und ich bin gerade gegangen snow blind versuchen, um es zu beheben! Ihre Hilfe würde Massiv geschätzt.

Ich bin mit dem PageObject-Modell (denke ich!) meine tests. Ich habe ein Objekt, das repliziert das browsing und das hochladen eines Bildes, die ich habe zu nennen, ein AutoIt script zu bewerkstelligen. Dies funktioniert aber mit hochgeladen das Bild der 'upload' - button nicht gelegen obwohl es hat ein ID-Attribut.

Ist es korrekt aktiviert wird nach der Datei-Auswahl unsicher ist, was mir fehlt.

Den code für die PageObject ist:

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();
}  

Bin ich dann den Aufruf der ' AddImage ' - Methode von der test-Klasse mit dem folgenden:

[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();
}

Aus irgendeinem Grund ist es nicht zu finden/Klick auf den 'action1' upload-button. Ich habe versucht, den Wechsel zurück zu den "FileDetails" - Fenster aber das funktioniert auch nicht.

Irgendwelche Ideen, was ich bin fehlt???

FYI - der code für die Schaltfläche Upload wird:

<input type="Submit" value="Upload" id="action1" disabled=""/>

UPDATE - die geänderten + arbeiten PageObject-Methode sieht nun wie folgt aus:

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
}   

InformationsquelleAutor Woodman81 | 2012-11-05

Schreibe einen Kommentar