R - Rselenium - navigate drop down menu / list / box using = 'id'

眉间皱痕 提交于 2019-12-06 14:14:16

With a little knowledge about XPath, adapting the linked solution which using XPath for your case should be straightforward, for example :

option <- remDr$findElement(using = 'xpath', "//select[@id='main_ddYear']/option[@value='2014']")
option$clickElement()

Brief explanation about the XPath :

  • //select[@id='main_ddYear'] : Find <select> element, anywhere in the HTML, where id attribute value equals 'main_ddYear'
  • /option[@value = '2014'] : From such <select> element, return child <option> where value attribute value equals '2014'.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!