Selenium: Change By-instance or concat two By-instances
In addition to what @SiKing said, I would also recommend looking at the ByChained
class (see here for javadocs).
Example on how to use it:
driver.findElements(new ByChained(By.id("product-table"), By.className("quantity")));
Not sure if this addresses OP's question directly, but still very useful.
You have two options:
You can do something like:
WebElement parentEl = driver.findElement(By.xpath(""))WebElement childEl = parentEl.findElement(By.className(""))
Use the PageFactory
@FindBys
. See Selenium PageFactory and Selenium API.