2016-04-15 23 views
0

enter image description here私はウェブページ上の画像をクリックしようとしています。このイメージの XPathがある - // * [ID @ = 'のGridView-1018'] /テーブル/ TBODY/TR [3]/TD [7]/DIV/A/IMGselenium webdriverの画像をクリックするには

HTMLコードは -

<td class=" x-grid-cell x-grid-cell-gridcolumn-1016 ">`<div class="x-grid-cell-inner " style="text-align: center; ;">`<a href="http://demo.webshopondemand.com/Shop/AbzorbDevelopment/Store/" target="_blank">`<img src="/admin/templates/images/house.png" style="background-color: transparent;"/>` 

ここにすべて下記の方法で試みたが、同じエラーMSGました "要素を見つけることができません: - 。

  1. driver .findElement(Byxpath(" .//*[@id= 'gridview-1018']/table/tbody/tr [3]/td [7]/div/a/img "))。クリック();

  2. WebElement temp = driver.findElement(By.xpath( "// img [(@src、 '/ admin/templates/images/house.png')]")); temp.click();

  3. WebDriverWait待機=新しいWebDriverWait(ドライバ、60); wait.until(ExpectedConditions.visibilityOfElementLocatedBy.cssSelector( "x-grid-cell-inner.a.img")))); driver.findElementBy.cssSelector( "X-グリッドセル-`inner.a.img"))。(クリック)

4. driverfindElement(By.cssSelector`( "a [href = 'AbzorbDevelopment']"))。

ありがとうございました!

答えて

0

こんにちはラジ、すなわち 使用アクションクラス

Actions act = Actions(driver); act.moveToElement(xpath).click().build().perform();

しかし、その代わりに、このような絶対のXPathの言ったことを、あなたはCSSのために試みることができるようにしてください

構文以下
Actions act = new Actions(driver); 
act.moveToElement(xpath).click().build().perform(); 
+0

返信いただきありがとうございます。 WebElement shop = driver.findElement(By.xpath( "// * @ @ id = 'gridview-1018']/table/tbody/tr [3]/td [7]/div/a/img ")))); \tアクションactions = newアクション(ドライバ); \t actions.moveToElement(ショップ).click()。perform();受け取ったエラーmsg:{"method": "xpath"、 "selector": "// * [@ id = 'gridview-1018']/table/tbody/tr [3]/td [7]/div/a/img "} – Rupali

+0

はうまくいきましたか? –

+0

受信したエラーmsg:{"method": "xpath"、 "selector": "// * [@ id = 'gridview-1018']/table/tbody/tr [3]/td [7 ]/d iv/a/img "} – Rupali

0

とアクションクラスを使用してください以下に示す通り:

div.x-grid-cell-inner>a[href='http://demo.webshopondemand.com/Shop/AbzorbDevelopment/Store/']>img[src='/admin/templates/images/house.png']
あなたの最終的な実装は次のようになります10

WebElement shop = driver.findElement((By.css("div.x-grid-cell-inner>a[href='http://demo.webshopondemand.com/Shop/AbzorbDevelopment/Store/']>img[src='/admin/templates/images/house.png']"))); 

アクションアクション=新しいアクション(ドライバ); actions.moveToElement(ショップ).click()。build()。perform();

注意:上記のCSSパスは、あなたの質問に記載したソースコードに基づいて作成されています。

関連する問題