Reputation: 83
Code:
String ButtonHolder = driver.findElement(By.xpath("//div[@id='block-success']//button")).getAttribute("text");'
System.out.println(ButtonHolder);
HTML
<button class="join-btn explore-flock">Explore Flock</button>
how do i check for the content "Explore Flock" from this code
Upvotes: 1
Views: 91
Reputation: 625
You can get button text using
getText
tag
System.out.println(driver.findElement(By.id("")).getText());
Upvotes: 1
Reputation: 52685
You need to use getText()
method or getAttribute("textContent")
or getAttribute("innerText")
instead of getAttribute("text")
as WebElement
has no such attribute as text
Upvotes: 2