Issue
I am new to selenium webdriver. I want to extract the value from the Ul class and store it in a variable but i am not able to do so
this is what i tried WebElement testuser = driver.findElement(By.cssSelector(".box ul.form li:nth-child(4)"));
div class="box" ul class="form"
<li><h4>First Name</h4></li>
<li>Faleata</li>
Its saying unable to locate the elements
Solution
To handle dynamic element use WebDriverWait
and try the below xpath
.
WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='box']/ul[@class='form']//li[./h4[text()='First Name']]/following::li[1]")));
System.out.println(element.getText());
Answered By - KunduK
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.