I want to extract the string value (Email is verified successfully!) from the md-card
using Selenium.
<md-card ng-if="$ctrl.isMyCompany && $ctrl.showVerified" class="ng-scope _md">
<md-card-content class="tradingPartnerVerification-warn ng-binding layout-align-start-center" layout-align="start center">
<md-icon class="myCompany-verifiedEmailIcon" md-svg-icon="check-circle" role="img" aria-label="check-circle">
<svg xmlns="http://www.w3.org/2000/svg" fit="" height="100%" width="100%" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24" focusable="false">
<g id="check-circle">
<path d="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M11,16.5L18,9.5L16.59,8.09L11,13.67L7.91,10.59L6.5,12L11,16.5Z"></path>
</g>
</svg>
</md-icon>
Email is verified successfully!
</md-card-content>
</md-card>
I'm using .Net with NUnit framework. My code is below.
string ActualEmailVerifiedText = diver.FindElement(By.XPath("//md-card-content[@class='tradingPartnerVerification-warn ng-binding layout-align-start-center']")).Text;
I think it is possible that some class is being added in md-card-content
in runtime ( assuming you are misspeling driver only here )
Try this:
string ActualEmailVerifiedText = driver.FindElement(
By.XPath("//md-card-content[contains(@class,'tradingPartnerVerification-warn')]")
).getAttribute('textContent');
To extract the string Email is verified successfully! you need to induce WebDriverWait for the text to render within the HTML as follows :
wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
string myElement = wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.XPath("//md-card[@class='ng-scope _md']/md-card-content[@class='tradingPartnerVerification-warn ng-binding layout-align-start-center']"),"Email is verified successfully!"));
Console.WriteLine(myElement.Text);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.