Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Display results as :
Advanced Search

Go down
Posts : 1
Join date : 2017-06-06

If element exists/wait for when using PageFactory with C# Empty If element exists/wait for when using PageFactory with C#

Tue Jun 06, 2017 1:18 am

I need to click an okay button which might appear after completing a field - it might take 5 seconds to appear. So i need IF Wait for existence 5 seconds. I'm using C# PageFactory as well.

FindsBy(How = How.Name, Using = "OK")]
private IWebElement alertOKBtn;

public void PopulateFields //method to populate the form
     // Populate fields
     dateFromField.SendKeys(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));
     // Click on this field
     //OK button might appear, might take 5secs - pseudcode
     if ( alertOKBtn exists, wait for it for 5 secs.. )

     //continue populating form


Not sure how to do the If element exists, i could just put a 5 second sleep before the IF statement button but I wondered if there was a better way to check for both?

Back to top
Permissions in this forum:
You cannot reply to topics in this forum