點擊我已經得到了由Drupal的,看起來或多或少像(以簡化形式)產生的HTML貝哈特如何將其他元素
<fieldset data-drupal-selector="ts-and-cs" id="edit-fieldset-ts-and-cs" class="js-form-item">
<label class="js-form-type-checkbox js-form-item-ts-and-cs" data-validation="single-checkbox">
<input required="required" class="required form-checkbox" data-drupal-selector="edit-ts-and-cs" type="checkbox" id="edit-ts-and-cs" name="ts_and_cs" value="1" aria-required="true">
<span class="checkbox-label">I have read and agree to <a href="http://domain/tc.pdf">Terms & Conditions</a> *</span>
</label>
</fieldset>
由於看中CSS和JS有內置不錯的複選框它連接到跨度CSS爲:: before僞元素,從而最終渲染HTML看起來或多或少像
<span class="checkbox-label">
::before
"I have read and agree to "
<a href="http://domain/tc.pdf">Terms & Conditions</a>
" *"
</span>
在同一時間輸入元素變爲隱藏,當然還有不可訪問的貝哈特任何試圖接球它會拋出類似的錯誤:
When I check "edit-ts-and-cs"
Element is not currently visible and so may not be interacted with
現在的問題是,什麼樣的用戶真正點擊,確認同意T &銫實際上是span.checkbox-label::before
但這種選擇被拒絕,因爲CSS選擇器不支持他們https://symfony.com/doc/current/components/css_selector.html,這是PHP水貂重要組成部分這樣
Pseudo-elements are not supported. (Symfony\Component\CssSelector\Exception\ExpressionErrorException)
實施投擲錯誤,當我試圖忽略::之前選擇的任何企圖造成點擊動作捕捉現有鏈接如下href和導航離開該頁面PDF文檔。
任何想法如何解決它,並迫使Behat產生正確的JS點擊?
這當然都是關於@Javascript模式的。在非JS模式下操作並且直接檢查輸入是沒有問題的,因爲在這種情況下它們是可見的。
你能給這個類型的元素的演示頁面的鏈接? – lauda