问题描述:

Here is my code,

The waitForSelector with the same selector works fine before dynamic dom manipultation. not sure if this is a bug.

casper.start("http://www.collierscanada.com/en/Properties?t=2")

# works here

casper.waitForSelector('#propertiesListView')

# changing the number of results displayed per page

casper.click('#dk_container_main_0_results_propResultsPerPage > a > span.dk_arrow > span') casper.waitForSelector('#dk_container_main_0_results_propResultsPerPage.dk_open')

casper.click('#dk_container_main_0_results_propResultsPerPage > div > ul > li:nth-child(6) > a')

# same selector does not work here

# some dynamic dom manipulation is happening in between

casper.waitForSelector('#propertiesListView')

Error

[warning] [phantom] Casper.waitFor() timeout

[error] [phantom] Wait timeout of 15000ms expired, exiting

网友答案:
casper.start("http://www.collierscanada.com/en/Properties?t=2")
casper.waitForSelector('#propertiesListView', function() {
    casper.click('#dk_container_main_0_results_propResultsPerPage > a > span.dk_arrow > span')
});
casper.waitForSelector('#dk_container_main_0_results_propResultsPerPage.dk_open').thenClick('#dk_container_main_0_results_propResultsPerPage > div > ul > li:nth-child(6) > a')
casper.waitForSelector('#propertiesListView')
相关阅读:
Top