everyone! I'm stuck with following problem: There is some
SearchContext searchContext;
By by;
which could be WebDriver or WebElement. Assume that both of them are already initialized (and we don't know how); Now we want to find elements with such xpath, seems to do following
List<WebElement> elements = searchContext.findElements(by);
But, if searchContext is WebElement and
by = By.xpath("//div");
it wouldn't work! (no elements would be found), because we need to do
by = By.xpath("./div");
(see Locating child nodes of WebElements in selenium) But, how i've mentioned, we know nothing about how by was initialized;
So, my question is: is there any way to find elements properly despite the problems above? I've got two variables: by and searchContext, and I should to find specified element in searchContext.