2016-09-22 7 views
0

それぞれに送信ボタンが付いた2つの異なるページがあります。 1つのページ送信ボタン・レジスタには、クリックとテストが続行されます。 2番目のページでは、Seleniumがボタンをクリックしたことがわかりますが、ボタンはクリックを登録せず、テストは失敗します。 ワーキングボタン:Selenium ChromeDriverを使用してページの[送信]ボタンが.click()コマンドに反応しません

<div class="clearfix"> 
    <button id="form2:btnContinue" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-right fr" type="submit" onclick="PrimeFaces.ab({s:"form2:btnContinue",u:"form1 form2 form3 form2:btnContinue"});return false;" name="form2:btnContinue" role="button" aria-disabled="false"> 
    <span class="ui-button-icon-right ui-icon ui-c fa fa-caret-right"></span> 
    <span class="ui-button-text ui-c">Continue</span> 
    </button> 
    </div> 
    </div> 

非稼働ボタン:

<div class="clearfix "> 
<button id="form:j_idt210" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only fr" type="submit" onclick="PrimeFaces.ab({s:"form:j_idt210",u:"form form2 confirmationPanel"});return false;" name="form:j_idt210" role="button" aria-disabled="false"> 
<span class="ui-button-text ui-c">Submit Payment</span> 
</button> 
</div> 
</div> 

私は同様に両方Webelementsを宣言します。

@FindBy(xpath = "//*[@id='form2:btnContinue']") 
    private WebElement processPaymentButton; 

非稼働ボタン:ボタンの作業も

@FindBy(xpath = "//*[@id='form:j_idt210']") 
    private WebElement submitFormButton; 

PageObjectsが完全に同じに見えます。ワーキングボタン:

public void setProcessPayment() { 
     WebDriverWait wait = new WebDriverWait(driver, 9); 
     wait.until(ExpectedConditions.visibilityOf(processPaymentButton)); 
     wait.until(ExpectedConditions.elementToBeClickable(processPaymentButton)); 

     processPaymentButton.click(); 

     wait.until(ExpectedConditions.visibilityOf(verificationInputField)); 

     sendKeysElement(verificationInputField, "1111"); 
     sendPaymentButton.click(); 
    } 

非稼働ボタン:

public void setProcessPayment() { 
     WebDriverWait wait = new WebDriverWait(driver, 9); 
     wait.until(ExpectedConditions.visibilityOf(submitFormButton)); 
     wait.until(ExpectedConditions.elementToBeClickable(submitFormButton)); 

     submitFormButton.click(); 

     wait.until(ExpectedConditions.visibilityOf(authorizationTokenField)); 

     sendKeysElement(authorizationTokenField, "1111"); 
     authorizePaymentButton.click(); 
    } 

私は、スクリプトまたはアクション、.sendKeys(Keys.ENTER)に変更.click()を試してみました。基本的には私が見つけたすべてを試しました。私はまた、ボタンがアクセスされる方法を変更する(CSS、ID、異なるXpathアプローチ)。動作中のテストはありませんが、セレンがボタンをクリックしたことがはっきり分かります。 ButtonはSeleniumと一緒に作業していましたが、停止していました。

私たちは、Selenium 2.47.1と最新のChromeDriverを使用しています。ボタンは手動でクリックすると機能します。 ありがとうございます。

注:問題は、セレンよりもボタン自体に関連しています。あなたが私たちにボタンを機能させる方法をヒントにすれば、感謝するでしょう。

+0

手動でクリックすると機能しますか? – Guy

+0

ボタンをクリックする前にボタンが表示/有効になっているかどうか確認してみましたか? – JDelorean

+0

質問が更新されました。はい、手動でボタンをクリックすることは可能ですし、それは動作します。表示可能かクリック可能かもチェックしています。私はそれが有効になっている場合(それを無効にするべきではないはず)、私はそれが有効になっているかどうかを確認する方法を試すことができますか? –

答えて

0

上記の「銀行コード」コンポーネントを使用して問題全体を解決します。このコンポーネントには、可能な結果(取引に使用される異なる銀行コードと運河)を含むテーブルが表示される自動充填機能が含まれています。
全体的な問題は、このコンポーネントに送信していました。チャンネルに銀行コードを送信していました。コンポーネントにJavaが入り込み、ボタンが機能しなくなってしまいました。私はこれがSelenium IDEで私のテストを試しているのを見つけました。今はその仕事。
この問題から学んだことは、ページ上の各コンポーネントがお互いに干渉し、テストを調整するだけでボタンが機能することです。

関連する問題