RSelenium-在网络划痕时访问下拉元素时出错

时间:2017-02-23 11:26:21

标签: r selenium-webdriver rselenium

我尝试了所有方法来自动化 Rselenium 中的下拉菜单选项?特别是,我可以使用findElement选择下拉框,但如何选择一个选项呢?

http://localizador.extra.com.br/storeSearch/?organization=EXTRA

我正试图抓住这个网站。

我试过的代码。

for(i in 2:15){
 #This part of code is not able to change the option in dropdown 
 webElem1a <- remDr$findElements(using='xpath',paste("//[@id='state']/option[",i,"]"))
 webElem1a$clickElement()
 loadmorebuttons<- remDr$findElement(using = 'css selector',".hidde")
 loadmorebuttons$clickElement()

 Sys.sleep(5)


#Below this code works properly
#Check the total Number of stores Available
  webElem1a<-remDr$findElements(using = 'css selector',".storesFound")
  Total_stores<-unlist(lapply(webElem1a,function(x){x$getElementText()}))
  Total_stores<-as.numeric(Total_stores)

#Load More view  
  if(Total_stores >= 7){
    for(j in 1:58){
      abc<-remDr$findElement(using = 'css selector',".moreResults")
      abc$clickElement()
    }
  }else{
    print("")
    }

0 个答案:

没有答案