<table id="ext-comp-1389" class="x-btn x-btn-text-icon " cellspacing="0" style="width: auto;">
<tbody class="x-btn-small x-btn-icon-small-left">
<tr>
<tr>
<td class="x-btn-ml">
<td class="x-btn-mc">
<em class="x-btn-split" unselectable="on">
<button id="ext-gen128" class="x-btn-text create" type="button">New</button>
</em>
</td>
<td class="x-btn-mr">
<i> </i>
</td>
</tr>
<tr>
</tbody>
</table>
上記は、HTMLファイルに新規ボタンが存在する方法です...
ボタンの動作は、その横に「+」記号が表示されていることです...「+」記号をクリックした場合にのみ、オプションのリストが表示されます....他の場所でクリックされた場合ボタンは何も起こりません...
Selenium Webdriverを使用して、これを自動化しようとしています...そして、以下はボタンをクリックする決定的な方法です...
private static int buttonwidth=24;//value got from firebug computation tab...
private static final int Xoffset = (buttonwidth/2)+6;
private static final int Yoffset = 0;
private static int buttonwidth1=42;
private static final int Xoffset1 = (buttonwidth/2)-6;
private static final int Yoffset1 = 0;
.......
......
.......
WebElement ele = driver.findElement(By.xpath("//*[@id='ext-gen128']"));//new button's id
Actions build = new Actions(driver);
build.moveToElement(ele, Xoffset, Yoffset).click().build().perform();
WebElement ele1 = driver.findElement(By.xpath("//*[@id='ext-comp-1389']/tbody/tr[2]/td[2]/em"));
Actions build1 = new Actions(driver);
build1.moveToElement(ele, Xoffset1, Yoffset1).click().build().perform();
ボタンのレイアウトは次のとおりです。Em クラスの幅は 42、ボタンの幅は 24 です..それらのスナップショットも...
誰でもこれで私を助けてもらえますか? どの座標とオブジェクトをターゲットにする必要がありますか?