java - @Findby vs. By cons and pros? -


i started pagefactory framework , started using @findby without knowing it, besides reading advanced method.

what realized expectedconditions.presenceofelementlocated not work webelements. had use .visibilityof not same, , won't perform actions on elements.

so changed method , locators work fine again.

is by class more robust storing elements?

which less problem prone? @findby or by

@findby attribute helpful static elements. elements not loaded dynamically can mapped in cleaner way using @findby attribute. using expected conditions because elements not loaded instantly , selenium needs wait element load or regular check it's existence. in cases, @findby not work , have use by selectors. in such case create private fields in order reduce code duplications. per knowledge, using @findby cleaner way element mapping in page object pattern not possible use in every scenario , that's benefit of using that.

example of how private field can used elements mapping

private static readonly testselector = by.xpath("your xpath");  public void clickupdate() {     //use same selector/field     driver.findelement(testselector).click(); }  public void clickupdate2() {     //use same selector/field     driver.findelement(testselector).click();     } 

note: c# code


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -