xパスが要素を選択しても、私はjava executorで試しましたが、コード実行時には、カート内の最初の要素の更新ボタンのみをクリックすることができます。私は、画像を添付したショッピングカートのページの更新ボタンをクリックする方法 - Url = "http://live.guru99.com/"
: のURL =は "http://live.guru99かつて私はリストにあったテキストボックスを追加したカート内の3つの製品を設置した後、ここで
:以下のコードです。 COM /」
List<WebElement> li2 =driver.findElements(By.xpath(".//td[@class='product-
cart-actions']/input"));
for(int j=0;j<li2.size();j++)
{
if(j==0)
{
li2.get(j).clear();
li2.get(j).sendKeys("4");
driver.findElement(By.xpath(".//td[@class='product-cart-actions']/button[@title='Update']")).click();
li2 =driver.findElements(By.xpath(".//td[@class='product-cart-actions']/input"));
}
else if(j==1)
{
li2.get(j).clear();
li2.get(j).sendKeys("2");
//wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//td[@class='product-cart-actions']/button[@title='Update' and @type='submit']")));
//driver.findElement(By.xpath(".//td[@class='product-cart-actions']/button[@title='Update' and @type='submit']")).isDisplayed();
WebElement element = driver.findElement(By.xpath(".//td[@class='product-cart-actions']/button[@title='Update' and @type='submit']"));
try {
if (element.isEnabled() && element.isDisplayed()) {
System.out.println("Clicking on element with using java script click");
((JavascriptExecutor) driver).executeScript("arguments[0].click();", element);
} else {
System.out.println("Unable to click on element");
}
} catch (StaleElementReferenceException e) {
System.out.println("Element is not attached to the page document "+ e.getStackTrace());
} catch (NoSuchElementException e) {
System.out.println("Element was not found in DOM "+ e.getStackTrace());
} catch (Exception e) {
System.out.println("Unable to click on element "+ e.getStackTrace());
}
// if (element.isDisplayed()) {
// element.click();
//}
li2 =driver.findElements(By.xpath(".//td[@class='product-cart-actions']/input"));
}
else
{
li2.get(j).clear();
li2.get(j).sendKeys("3");
WebElement element1 = driver.findElement(By.xpath(".//td[@class='product-cart-actions']/button[@title='Update']"));
if (element1.isDisplayed()) {
element1.click();
}
}
@guy:これを見てもらえますか? –