2016-07-11 9 views
0

このbehatコードシナリオがタブ2節(When I click element with id "edit-submit--22")にタブの1セクションで働いていないが、 enter image description herebehat + minkのonClick属性にアクセスする方法は?

Tab 1: 
<span class="form-submit-wrapper"><input type="submit" id="edit-submit--3" name="op" value="Inschrijven" class="form-submit"></span> 

Tab 2: 
<span class="form-submit-wrapper"><input onclick="return validate_course_anywhere(this)" type="submit" id="edit-submit--22" name="op" value="Inschrijven" class="form-submit"></span> 

When I click element with id "edit-submit--3"下の画像のように私たちは、Tab1をセクションとTAB2セクションの「Inschrijven」という名前の2つのボタンがあります

       /** 
           * @When /^I click element with id "([^"]*)"$/ 
           */ 
           public function iClickElementWithId($class) { 
              $locator = "#$class"; 
              $element = $this->getSession()->getPage()->find('css', $locator); 

              if (null === $element) { 
                  throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator)); 
              } 

              $element->click(); 
              $this->getSession()->wait(1000); 
           } 

が、エラー・メッセージは、タブ2のセクションに表示されている:

Exception thrown by (//html/descendant-or-self::*[@id = 'edit-submit--22'])[1] 
Element is not clickable at point (813.5, 16.666671752929688). Other element would receive the click: <a href="/certificering" title="" class="menu__link"></a> 

答えて

0

セレクタがOKであるようですが、ここではクリック可能ではなく、他の要素が前面にあり、クリックを受け取ります。

可能な問題のいくつか:要素をロードするページについて 3.待機あなたが同じIDを持つ2つの要素を持っているし、最初の1が発見された2 見えますがクリックできないことするため 1.待機あなたはただ一つの属性のためのセレクタではなく、特定の方法でクリックする方法を持っている必要があり

[onclickの* =「some_value_from_attribute」]:のonClickを使用するには

を必要に応じて、あなたのようなCSSセレクタを使用することができます属性。

盲目的な待機を避けるためには、条件付き待機を使用するようにしてください。

関連する問題