こんにちは、私は、次のHTMLを切り取られている:Javaを使用してSeleniumのHTMLコードに続くWebElementを見つける方法は?
<tr rowid="0" class="addedrow rowselected datarow rowfocus">
....
<td positionindex="3" class="primary required">
<input type="text" class="editablecell" size="15">
</td>
<td positionindex="4" class="required">
<div class="select2-container editablecell" id="s2id_autogen1" style="width: 99%;" title="">
<a href="javascript:void(0)" onclick="return false;" class="select2-choice select2-default" tabindex="-1">
</a>
</div>
</td>
....
私はテキストフィールドにテキストを挿入する必要があります。私はこの特定のWebElement
をJavaでSeleniumを使って見つけるのが難しいです。
私はANSER hereに基づいて、この
WebElement box = driver.findElement(By.xpath("//input[(@type='text') and
(@class='editablecell')]"));
を試してみました。
注:この要素は、以下の構造である:スロー
<html> ....
<body> ...
<div id=topLeveWrapper> ...
<div id=header> ...
<div id=contentFrame> ...
<div id=leftSite> ...
<div id=rightSite> ...
<div id=pageID_123456> ...
<div id=gridViewID_98765> ...
<div id=tableWrapper> ...
<div id=twHEADER> ...
<div id=twBODY> ...
<table >
<thead> ...
<tbody>
<tr rowid=0 ...>
<td positionindex="3" class ="primary required"> <input type="text" class="editablecell" size="15">
</td>
....
</tr>
......................
Exeptionは次のとおりです。
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@type='text' and @class='editablecell']"}
(Session info: chrome=..)
情報:
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
誰もが、この上で私をしてくださいguidをすることはできますか?
おかげ
XPathに問題はありません。 Web要素がフレーム内にあるように見えます。それを確認しましたか? – Monika
@dhssa、問題のフィールドのURLと名前を教えてください。 – Deepak
あなたのxpathを見つけるためにfirebugとfirepathを使用してください。あなたがそれを見つけるのを助けると確信しています。必要に応じてxpathをカスタマイズすることができます。詳細については、次のリンクを参照してください:https://www.guru99.com/xpath-selenium.html –