久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

waitForSelector 通過,但 assertExists 對同一個選擇器

waitForSelector passes, but assertExists fails for the same selector(waitForSelector 通過,但 assertExists 對同一個選擇器失敗)
本文介紹了waitForSelector 通過,但 assertExists 對同一個選擇器失敗的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

當我調用以下函數時,waitForSelector 為選擇器"傳遞,但 assertExists 對同一選擇器失敗.怎么可能?

When I call the following function, waitForSelector passes for 'selector', but assertExists fails for the same selector. How is it possible?

casper.waitForSelector(selector, function() {
    casper.test.assertExists(selector, sectionName + " opened up successfully.");
}, function() {
    casper.test.fail(sectionName + " did not load in given time");
}, max_timeout);

這里是使用 :nth-child 重現問題的完整示例 選擇器.

推薦答案

這是一個已知的錯誤(參見 #11632,#11737)在 WebKit 的 Qt4 分支中(來自2010).當使用 :nth-child():nth-of-type() CSS3 選擇器時會發生這種情況.選擇器第二次運行時,它返回不同的結果(大部分時間是 null).唯一已知的解決方法是使用 XPath 表達式而不是 CSS3 選擇器.此錯誤已在 PhantomJS 2 中修復,因為它使用 WebKit 的 Qt5 分支(版本 538.1).

This is a known bug (see #11632, #11737) in the Qt4 fork of WebKit (from 2010). It happens when :nth-child() or :nth-of-type() CSS3 selectors are used. The second time the selector is run, it returns a different result (most of the time null). The only known workaround is to use XPath expressions instead of CSS3 selectors. This bug is fixed in PhantomJS 2 as it uses a Qt5 fork of WebKit (version 538.1).

這是在 http://example.com 上重現問題的最小腳本(修改自 這里):

This is a minimal script to reproduce the issue on http://example.com (modified from here):

var casper = require('casper').create(),
    x = require('casper').selectXPath;

casper.start('http://example.com', function() {
    var selector = 'p:nth-child(3) > a',
        xpSelector = '//*[local-name()="p" and position()=3]/a';
    var first = this.exists(selector);
    var second = this.exists(selector);
    if(first !== second) {
        console.error('Expected First selector to equal the Second');
    } else {
        console.log('Passed');
    }
    first = this.exists(x(xpSelector));
    second = this.exists(x(xpSelector));
    if(first !== second) {
        console.error('Expected First selector to equal the Second');
    } else {
        console.log('Passed');
    }
}).run();

輸出:

標記是:

Markup is:
<h1>文本</h1><p>文本</p><p><a href="url">文本</a></p></div>

<div> <h1>text</h1> <p>text</p> <p><a href="url">text</a></p> </div>

XPath 表達式看起來有點尷尬,因為它直接再現了 CSS 選擇器的預期行為.通常人們會寫 //p[2]/a.

The XPath expression looks a little awkward, because it directly reproduces the intended behavior of the CSS selector. Normally one would write //p[2]/a.

這篇關于waitForSelector 通過,但 assertExists 對同一個選擇器失敗的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Is Math.random() cryptographically secure?(Math.random() 在密碼學上是安全的嗎?)
Secure random numbers in javascript?(在javascript中保護隨機數?)
How to avoid multiple token refresh requests when making simultaneous API requests with an expired token(使用過期令牌發出同時 API 請求時如何避免多個令牌刷新請求)
JWT not decoding quot;JWT malformedquot; - Node Angular(JWT 未解碼“JWT malformed;- 節點角度)
How to invalidate a JWT token with no expiry time(如何使沒有到期時間的 JWT 令牌無效)
Authorization header in img src link(img src 鏈接中的授權標頭)
主站蜘蛛池模板: www.日本国产 | 日韩精品一区二区三区在线播放 | 日韩在线欧美 | 狠狠色综合欧美激情 | 久久不卡日韩美女 | 成人国产一区二区三区精品麻豆 | 久久久久国产精品一区二区 | 欧美亚洲在线 | 黄色一级视频免费 | 91大神在线资源观看无广告 | 国产精品区二区三区日本 | 日韩成人免费中文字幕 | 97精品国产一区二区三区 | 看亚洲a级一级毛片 | 国产精品一区二区三区四区 | 日韩一区二区免费视频 | h漫在线观看 | com.国产| 欧美一区2区三区4区公司 | 欧美日韩91| 精品久久一区 | 性欧美hd | 亚洲人一区 | 天天射中文 | 久久天堂 | 二区久久 | 人人干人人看 | 日日骚av | 99在线免费视频 | www.99热这里只有精品 | 成人视屏在线观看 | 成人久久久 | 精品一区二区三区日本 | 欧美午夜影院 | 91av视频在线| 中文字幕一区二区三区四区五区 | 蜜桃精品视频在线 | 久久久久久久av麻豆果冻 | av在线影院 | 欧美在线a | 亚洲iv一区二区三区 |