html - R - RSelenium, press Next button & change dropdown options to 25 -
op warning: not @ html.
i trying use rselenium remote-drive (browsername='phantomjs') scrape links on login required page. able handle login part when try extract links in table, cannot scrape of them because;
1- table has limited view of 10-row displays. can altered using dropdown option 25.
things have tried: option <- remdr$findelement(using = 'xpath', "//*/option[@value = '25']") option$clickelement() result error: element hidden 2- cannot press next button @ bottom of table see links in next page.
similarly, think able find 4 buttons using findelement(). when run; buttons <- remdr$client$findelement("class name", "ag-paging-button") nextbutton <- buttons[[3]] nextbutton$click() nextbutton$clickelement() then run link extraction "href" same 10 links if nothing had happened.
my issue can fixed getting part 2 done, appreciate if answer first 1 too.
here how selected chunks of html source code looks like.
<div class="pxl-aggrid-pagesize"> "displaying: " <select id="pxl-ag-grid-pageselect"> <option value="10">10</option> <option value="15">15</option> <option value="20">20</option> <option value="25">25</option> </select> </div> <div class="ag-paging-panel ag-font-style"> <span class="ag-paging-page-summary-panel"> <button class="ag-paging-button" ref="btfirst" disabled type="button">first</button> <button class="ag-paging-button" ref="btprevious" disabled type="button">previous</button> " page " <span ref="lbcurrent">1</span> " of " <span ref="lbtotal">0</span> <button class="ag-paging-button" ref="btnext" disabled type="button">next</button> <button class="ag-paging-button" ref="btlast" disabled type="button">last</button>
i able mousemovetolocation() function. surely, need modification based on layout used website itself. however, might to; code attached below.
allbuttons <- remdr$client$findelements("xpath", "//button[@class='ag-paging-button']") allbuttonstext <- sapply(allbuttons, function(x)x$getelementtext()) nextbuttonnumber <- grep('next', unlist(allbuttonstext)) remdr$client$mousemovetolocation(webelement=allbuttons[[nextbuttonnumber]]) remdr$client$click(1)
Comments
Post a Comment