stuck on an issue

16 views
Skip to first unread message

Rahul Rana

unread,
Nov 19, 2016, 8:54:52 PM11/19/16
to webdriver
Hi All,

When I run class infratestcases it shows no element found. I am trying to use a wait method for sync issues with a pagefactoryclass. All files are in same package. 
Could you help me ??

I am automating angular js application so this wait library will sort out my sync issues.

Thanks guys !!!!
BaseClass.java
Factory.java
InfraTestCases.java
WaitTypes.java

darrell grainger

unread,
Nov 20, 2016, 6:45:26 PM11/20/16
to webdriver
First, it has been noted by people far smarter than me that debugging an application is harder than writing it. From this I gather that my design should be easier to debug than it is to write. If I use clever things like factories to make it easy to write but then I cannot debug it when something goes wrong, I got things backwards.

That said:

InfraTestCases has spf.username.sendKeys("admin");. From this I need to understand what spf is. Since it is not defined in the class, it must be inherit from the base class BaseClass. When I look at BaseClass I see spf = new Factory(driver);. So spf is a Factory initialized with driver. Now things look a little odd to me. All the variable declarations have a @FindBy annotation EXCEPT the username variable. The @FindBy is commented out. Is this an issue? I've not use a PageFactory before. So I don't know.

If this isn't an issue, The username is initialized with WaitTypes.isElementPresent. When I look at the WaitTypes I see that the isElementPresent isn't using a WebDriverWait condition. You seem to have reinvented the concept. If using the WebDriverWait method didn't work for you, you switched to creating your own method and it still doesn't work then whatever reason you suspected the WebDriverWait for failing was probably wrong. I'd try to come up with another theory on why it is failing. Maybe do a little debugging. Step through the code. If it works than it is a timing issue. Run through the code with print statements. See what the state is at each step (or before/after each line of code). Maybe you are making an assumption you are unaware of.

Personally, your isElementPresent isn't very efficient. I would use a findElements (notice this is plural). If the result is equal 0 (zero) then you did not find the element. I would NEVER use a try/catch on a findElement in this situation.

Darrell
Reply all
Reply to author
Forward
0 new messages