2017-09-15 8 views
0

セレンの[続行]ボタンをクリックするのに苦労しています。私は.click()を使用しようとしますが、要素はクリック可能ではありません。私は要素が手前に見えるのを待ってみましたし、この記事の解決策に続いて試してみました。Debugging "Element is not clickable at point" errorでも運はありません。セレン内のボタンをクリックできません

これは問題である理由は誰にも分かりますか?私はこれをChromeでテストしています。私は本当にのThread.sleep使用したいが、ちょうど待ち時間を作成するために、今のためにそれを使用していない

<div class="basket-summary__continue"><button data-href="" data-component="Booking/Navigation/ContinueButton" class="bttn bttn--primary bttn--full-width"> 
    Continue 
</button></div> 

public void ClickContinue() 
    { 
     Thread.Sleep(10000); 
     _driver.FindElement(By.ClassName("basket-summary__continue")).FindElement(By.XPath("/html/body/div[2]/div[4]/div/div[2]/div[1]/div[1]/div[2]/div[2]/div[3]/button")).Click(); 
    } 

P.S。すなわち、表示され、有効になって - - ExpectedConditionsクラスを使用して

は、あなたがクリック可能となる元素を待つことができ

+0

例外の完全なスタックトレースを教えてください。 – Murthi

+1

_driver.FindElement(x.vpath = 'bttn - bttn - bttn - bttn - bttn - bttn - 全角' ')」))。クリック(); – iamsankalp89

+0

そのxpathは問題の主要な候補に見えます。今のところ

答えて

0
@FindBy(xpath = "//div[@class='basket-summary__continue']/button") 
private WebElement button; 

または

By buttonBy = By.xpath("//div[@class='basket-summary__continue']/button"); 

してください、以下のドキュメントを確認してください。

/*** 
* An expectation for checking an element is visible and enabled such that you can click it. 
* @param locator - used to find the element 
* @param timeout 
* @return the WebElement once it is located and clickable (visible and enabled) 
*/ 
public WebElement elementToBeClickable(By locator, int timeout) { 
    try { 
     return getWebDriverFluentWait(timeout) 
       .until(ExpectedConditions.elementToBeClickable(locator)); 
    } catch (Exception e) { 
     return null; 
    } 
} 

private Wait<WebDriver> getWebDriverFluentWait(int timeout) { 
    return new FluentWait<WebDriver>(driver) 
      .withTimeout(timeout, TimeUnit.SECONDS) 
      .pollingEvery(1, TimeUnit.SECONDS) 
      .ignoring(NoSuchElementException.class); 
} 

最後に、我々は次のように機能を実行することができます。私は、Java上でより多くのですが、私たちは他の言語についても同様のソリューションを持っていると思うこと

WebElement btnContinue = elementToBeClickable(buttonBy, 10); # wait for element clickable within 10 seconds timeout. 
btnContinue.click(); 

//申し訳ありません。

+0

こんにちはトニー、すみません、私は少し交流#noobですあなたが最初に私にこの最初のものを作成してもらいたいですか?public void ClickContinue() { _driver.FindElement(By.XPath( "// div [@ class = 'basket-summary__continue']/button")); プライベートWebElementボタン。 } – BruceyBandit

+0

そして、残りのコードは下に移動しますか? – BruceyBandit

+0

私は答えでさらにいくつかのコードを更新しました。それが動作することを願って! –

関連する問題