在多个page.click上捕获多个xhr响应(无需重新加载或更改页面)

时间:2018-05-17 23:28:13

标签: node.js asynchronous async-await puppeteer

static void Main(string[] args)
{
    Preferences preferences = null;
    var xmlString = Data.XML;

    using (var stream = new StringReader(xmlString))
    {
        var serializer = new XmlSerializer(typeof(Preferences));
        preferences = (Preferences)serializer.Deserialize(stream);
    }

    var node0 = new Font()
    {
        Fname = "New One",
        Role = "console",
        Size = "12"
    };

    var node1 = new Font()
    {
        Fname = "Helvetica",
        Role = "titles",
        Size = "10"
    };

    if (preferences.Font.Contains(node0))
    {
        // Not expecting to enter here
        Console.WriteLine($"'{nameof(node0)}' is already present");
    }

    if (preferences.Font.Contains(node1))
    {
        Console.WriteLine($"'{nameof(node1)}' is already present");
    }
}

作为上述示例的结果,page.on仅捕获对应于span#first的ajax请求。未捕获跨度#second和span#third。 page.waitForNavigation的使用似乎没有任何效果。

0 个答案:

没有答案