I have been trying to read the content inside an html tag which has features like ::before and ::after using selenium webdriver (Java), but I'm having hard time to read those contents since they are dynamic.
For example, In the below HTML code,
<label class="radio radio-label-horizontal control-label" for="id_Fruit_1">
<input value="Banana" name="Fruit" id="id_Fruit_1" data-field-name="Choices" data-field-type="Structured" tabindex="2" type="radio">
<span class="radio-label">
::before
Banana
::after
</span>
</label>
That's a code snippet for a radio button which is selected, but when I switch the radio button to another choice, it simply removed ::after from the "span" element, and it did not make any change to the "input" element.
But when I did the below java selenium code, I only see 'Banana', and I was expecting to get '::before Banana ::after'
driver.findElement(By.cssSelector(".radio-label")).getText();
Can you please explain how I can find out whether my radio button is checked or not using selenium?
You can isSelected() method to figure out whether radio button is selected or not.
List radioBtn = driver.findElements(); boolean selected=false; selected=radioBtn.get(0).isSelected() will return true/false whether the button is selected or not. if(selected) //perform actions
您只能将文本传递到您的应用程序中,而不是像以下和祖先这样的 HTML 标签
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.