I am building a testing framework for my website I want to fully separate the framework away from test the issue is when I write a test sometimes the Assert needs time until it can be true, for example if I am on Upload file page and when the file is uploaded the website should display File uploaded successfully page but it will need to much time until the browser reaches this page
How should I force the Assert to wait sometime before it returns result?
some code that might explain my current way of work:
Upload Page Class
Public class UploadPage
{
[FindsBy(How = How.Name, Using = "upload-button")]
public IWebElement BtnUpload { get; set; }
public UploadPage()
{
PageFactory.InitElements(Driver, this);
}
public void UploadFile(string path)
{
//select file
BtnUpload.Click();
}
}
Successful Upload Page:
Public class UploadSuccessfulPage
{
[FindsBy(How = How.Name, Using = "success-message")]
public IWebElement LblSuccessMessage{ get; set; }
public UploadSuccessfulPage()
{
PageFactory.InitElements(Driver, this);
}
public bool IsAt()
{
Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(60))
//LblSuccessMessage can be found on page
}
}
Test Method:
public void TestUpload()
{
UploadPage uploadPage= new UploadPage ();
uploadPage.UploadFile(path);
UploadSuccessfulPage successPage= new UploadSuccessfulPage();
Assert.IsTrue(successPage.IsAt());
}
when I write my tests this way the assert do not wait despite that IsAt()
contains an implicit wait.
P.S: I am not intending to use Thread.Sleep();
.