Questions tagged [findby]

FindBy is a type of annotation used to mark a field on a Page Object to indicate an alternative mechanism for locating the element or a list of elements. Used in conjunction with PageFactory this allows users to quickly and easily create PageObjects.

FindBy is a type of annotation used to mark a field on a Page Object to indicate an alternative mechanism for locating the element or a list of elements. Used in conjunction with PageFactory this allows users to quickly and easily create PageObjects.

You can either use this annotation by specifying both "how" and "using" or by specifying one of the location strategies (eg: "id") with an appropriate value to use. Both options will delegate down to the matching By methods in By class.

For example, these two annotations point to the same element:

@FindBy(id = "foobar") WebElement foobar;
@FindBy(how = How.ID, using = "foobar") WebElement foobar;

and these two annotations point to the same list of elements:

@FindBy(tagName = "a") List<WebElement> links;
@FindBy(how = How.TAG_NAME, using = "a") List<WebElement> links;
155 questions
3
votes
2 answers

grails - findBy highest id AND another criteria

I've looked a bunch of answers to this question here on SO and elsewhere but all I can track down is cases where people just want to find the highest id, the max dateCreated or the latest db entry but what I want to do is retrieve the latest object…
SeriousLee
  • 1,301
  • 4
  • 20
  • 42
3
votes
1 answer

@Findby using xpath with index

Can I use @Findby and pass certain values as parameter? @FindBy("//div[contains(@class,'gallery_grid_image_caption gallery_grid_image_caption_padding')]"[$INDEX]) I know I can do this while using findElement. Kindly let me know if there is a…
Prakash P
  • 419
  • 1
  • 8
  • 18
3
votes
1 answer

Spring JPA repoistory findBy IN List - allow null

Short Description How do I make findByIn work with IN when the array list input is null. e.g. ignore it. What would your DAO for this look like? Longer description. Imagine you have creating a search for users page. in the application. You…
Robbo_UK
  • 11,351
  • 25
  • 81
  • 117
3
votes
1 answer

Spring boot data rest findby traverson to java object

my URI is http://localhost:8080/context/my-objects/search/findByCode?code=foo JSON response: { "_embedded" : { "my-objects" : [ { "code" : "foo", "description" : "foo description", "_links" : { "self" : { …
user1648825
  • 979
  • 11
  • 19
3
votes
2 answers

Selenium: Change By-instance or concat two By-instances

Is it possible to combine/concat two Bys? If I have one By By parentBy = new By.xpath(".//div[@class='parent']") and another By By childBy = new By.xpath(".//div[@class='child']") is it possible to concat the two Bys to a new one that has this…
Tobias
  • 2,945
  • 5
  • 41
  • 59
3
votes
1 answer

findBy multiple attributes (findAllWhere)

I have an object from which I must filter certain attributes, some of which could also be "null". I have a Filter object and a Product object. In the Filter object I have certain attributes reflecting the Product object which can be filled out or be…
fischer_zh
  • 730
  • 1
  • 8
  • 7
3
votes
3 answers

Multiple findby in symfony doctrine

I need to know if there is a way to do something like this: $customerClient = $clientTable->findByCustomerNumber($this->array_data[$rowIndex]['D']); $customerClient = $customerClient->findOneByEmpCartera($portfolio); I get this error message Call…
JERC
  • 1,584
  • 3
  • 17
  • 38
2
votes
3 answers

CakePHP 2.0.4 - findBy magic methods with conditions

I am trying to build a small cms to test CakePHP 2.x In my PagesController (for displaying single sites), I use this code: $page = $this->Page->findByNavtitle($name, array( 'conditions' => array( 'Page.visible' => '1', ), …
2
votes
1 answer

Error when using 'find_all_by_'

I get an error while using find_all_by_ controller @books = Book.find_by_author_id(4) View <%= @books.name %> This works. But when I replace find_by_ with find_all_by_ I get this error undefined method `name' I want to use find_all_by_ to fetch…
Isabella
  • 37
  • 4
2
votes
2 answers

findBy property in List SpringBoot JPA Repository
I have a one to many relationship between two objects in my database Story and Tag. I'm looking to to be able to get all Story objects that have a Tag object with the String name. Story.java @Entity @Table(name = "stories") public class Story { …
Jack Quigley
  • 23
  • 1
  • 3
2
votes
1 answer

sequelize - is it possible to use findByPk when Primary key is composite key?

I have model called session with composite key of three properties: seesionId, userNameId and accountId. In order to create new record I need to check if there's already session with the same userNameId and accountId. the API of findByPk: public…
ker3n.nn
  • 21
  • 1
  • 2
2
votes
1 answer

Getting an error while trying to use @FindBy annotation in selenium

I did come across this issue here but according to the thread the "error was gone, and I don't know how it was fixed"... got error while trying to use @FindBy annotation in selenium Here is the code I have written. The strange thing is I already…
2
votes
1 answer

Selenium: annotation type not applicable to this kind of declaration

Am I not using the @FindBy annotation correctly? package dur.bounceme.net.SeleniumBase; import java.util.logging.Logger; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import…
Thufir
  • 8,216
  • 28
  • 125
  • 273
2
votes
2 answers

Can @findby annotation be used in an interface with Selenium

Lets see below code: public interface HomePageObjects { @FindBy(xpath = "//*[@class='_2zrpKA']") WebElement UsernameField ; @FindBy(xpath = "//*[@class='_2zrpKA _3v41xv']") WebElement PswdField ; } public class HomePageTests…
2
votes
1 answer

how = How.ID in selenium

I've one small question, what's the difference beetween following lines in Selenium with Page Factory? @FindBy(id = "foobar") WebElement foobar; And @FindBy(how = How.ID, using = "foobar") WebElement foobar;
mtmx
  • 827
  • 1
  • 10
  • 31
1
2
3
10 11