与Selenium和WebdriverIO分页

时间:2017-03-13 20:35:24

标签: node.js selenium selenium-webdriver webdriver-io

我正在抓取一个网站(https://techtransfer.universityofcalifornia.edu/Default.aspx?RunSearch=true),使用WebdriverIO和Selenium来处理分页。我需要能够抓取页面上的所有链接,将它们推送到一个数组,然后导航到下一页并执行相同的操作,直到我到达结果的末尾。

下一个按钮结构如下。

<li class="next">
    <a id="ctl00_ContentPlaceHolder1_ucNCDList_ucPagination_nextPage" name="1" title="Next" onclick="javascript:showSpin(); return true;" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ContentPlaceHolder1$ucNCDList$ucPagination$nextPage&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))">
        <i class="demo-icon icon-right-open-1">&#xe83c;</i>                
    </a>            
 </li>
然后我打电话给

await client.click('#ctl00_ContentPlaceHolder1_ucNCDList_ucPagination_nextPage i')

当我这样做时,我收到此错误。

    { Error
  message: 'unknown error: Element <i class="demo-icon icon-right-open-1">...</i> is not clickable at point (442, 586). Other element would receive the click: <div class="middle-content">...</div>',
  type: 'RuntimeError',
  seleniumStack: 
   { status: 13,
     type: 'UnknownError',
     message: 'An unknown server-side error occurred while processing the command.',
     orgStatusMessage: 'unknown error: Element <i class="demo-icon icon-right-open-1">...</i> is not clickable at point (442, 586). Other element would receive the click: <div class="middle-content">...</div>\n  (Session info: chrome=56.0.2924.87)\n  (Driver info: chromedriver=2.28.455517 (2c6d2707d8ea850c862f04ac066724273981e88f),platform=Mac OS X 10.12.3 x86_64) (WARNING: The server did not provide any stacktrace information)\nCommand duration or timeout: 155 milliseconds\nBuild info: version: \'3.2.0\', revision: \'8c03df6\', time: \'2017-03-02 09:34:51 -0800\'\nSystem info: host: \'Robbys-MacBook-Pro.local\', ip: \'fe80:0:0:0:86:153c:7bdd:53f4%en0\', os.name: \'Mac OS X\', os.arch: \'x86_64\', os.version: \'10.12.3\', java.version: \'1.8.0_121\'\nDriver info: org.openqa.selenium.chrome.ChromeDriver\nCapabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.28.455517 (2c6d2707d8ea850c862f04ac066724273981e88f), userDataDir=/var/folders/89/rzglzpkn1x32wt29pff31zd40000gn/T/.org.chromium.Chromium.7xCPwY}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=56.0.2924.87, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}]\nSession ID: 717540fedaad0982a731fe8e2c012549' } }

本网站使用非常复杂的加密请求和分页,我想知道这是否与问题有关。如何使用WebdriverIO成功导航到下一页?

1 个答案:

答案 0 :(得分:0)

没关系!我使用WebdriverIO的execute方法来调用处理分页的页面上的函数。对刮刀来说有点强壮,但它有效!

stylesheetParams