こんにちは私は同じスパンクラスにあるが、名前がラベルタグにあるチェックボックスの隣に名前をキャプチャしようとしています。 getText()メソッドを使ってテキストをキャプチャしようとすると、空の名前になります。Selenium Webdriverキャプチャチェックボックスのテキスト
コードに表示する方法私はそれをやっています。
//to find the checkbox
@FindBy(how = How.ID, id = "ConstructionManagement")
private WebElement constructionMgmnt;
このgetTextを使用すると、空のテキストが表示されます。 getAttributeを使用したとき、私は付いたチェックボックスの実際の名前は、チェックボックスを符号化する方法$ PpyWorkPage $ pOutageRequest $ pConstructionManagement
constructionMgmnt.getText();
constructionMgmnt.getAttribute("name")
ページのソースで取得しています。
<span class="checkbox" data-ctl="Checkbox">
<input value="false" name="$PpyWorkPage$pOutageRequest$pConstructionManagement" type="hidden">
<input id="ConstructionManagement" class="checkbox chkBxCtl" value="true" name="$PpyWorkPage$pOutageRequest$pConstructionManagement" validationtype="true-false" pn=".ConstructionManagement" type="checkbox">
<label class=" cb_standard" for="ConstructionManagement">Construction Management</label>
</span>
は、誰もがチェックボックスIDを指している要素からテキストを取得するためにつかむ方法を考えることができ、または私は次のもののチェックボックスにテキストを取得するためにラベル付けするXPathを使用する必要がありますか?
//example of garbing the name of the Label (I tested this and it works)
driver.findElement(By.xpath("//label[@for='ConstructionManagement']"));
ありがとうございます。ここで
クイックリプレイをありがとう。 –
@TomaszWidaあなたの質問に応えたら答えを受け入れてください。ありがとう – DebanjanB