I have a weird problem:
When I locate an element via:
WebElement e1 = driver.findElement(By.xpath("//div1"));
WebElement e2 = e1.findElement(By.xpath("//.[@class='c2']"));
e2.click();
I can't click e2, because: "Element < div class="c2" > could not be scrolled into view."
BUT when I locate e2 via:
WebElement e2 = driver.findElement(By.xpath("//div1//.[@class='c2']"));
e2.click();
it works. (Also when checking e2.getLocation()
the coordinates are different, and only correct in the second snippet).
I think Selenium doesn't like the "//.", because:
WebElement e1 = driver.findElement(By.xpath("//div1"));
WebElement e2 = e1.findElement(By.xpath("div[@class='c2']"));
e2.click();
also works.
Any idea how I can use the any (.
) selector there? (.[@class='c2']
can not be found)
[EDIT] I already have e1 and therefore need to search on this element via e1.findElement(...)
question from:
https://stackoverflow.com/questions/65851452/element-not-clickable-when-using-findelement-on-another-webelement 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…