3

I have a function that takes a By element, By by = By.xpath("xpathString"). Inside my method I am using the following statement to find another WebElement

findElement(by).findElements(By.xpath(anotherXPathString))

Does anyone know a way to manipulate the first by so I can combine them so I can use one findElement function? I have looked on the Selenium By class page and it has no way to convert a By to a String or to combine to different By elements. My goal is to have it look like

By newby = (however we will combine the two by statements);
findElements(newby);

or

String newXPath = (however we convert the by to a string) + anotherXPathString;
findElements(By.xpath(newXPath));

1 Answer 1

7

Do you know ByChained class?

You can summarize By chain by ByChained use.

see: javadoc (http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/support/pagefactory/ByChained.html)

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.