title: Select option in dropdown box using Rselenium
body: <p>I'm trying to use RSelenium to select the theme 'loneliness' from the drop-down box in the tab mental health and wellbeing from <a href="https://analytics.phe.gov.uk/apps/covid-19-indirect-effects/#" rel="nofollow noreferrer">https://analytics.phe.gov.uk/apps/covid-19-indirect-effects/#</a>. I can get Rselenium to go the the mental health tab but I haven't had any luck in selecting the 'loneliness' theme. I would be grateful for any steer as I've reviewed many posts from Stack Overflow (you can chuckle at my many failed attempts) and still no joy.</p>
  <p>I would be really grateful for any pointers!</p>
  <pre><code>library(tidyverse)
  library(rvest)
  library(RSelenium)
  
  
  # Start Selenium server and browser
  
  driver &lt;- rsDriver(
    browser = &quot;chrome&quot;,
    chromever = &quot;97.0.4692.71&quot;  
  )
  
  remDr &lt;- driver$client
  
  # Navigate to wich tool
  remDr$navigate(&quot;https://analytics.phe.gov.uk/apps/covid-19-indirect-effects/&quot;)
  
  #changing the page to the mental health and well being tab
  ##avoided using href as the tab value keeps changing
  
  webElem &lt;- remDr$findElement(using = 'xpath', value = '//*[@id=&quot;page&quot;]/nav/div/ul/li[8]/a')
  
  # Highlight to check that was correctly selected - don't need but putting it in as a check
  
  webElem$highlightElement()
  
  # click the search link
  webElem$clickElement()
  
  
  # click the link
  webElem$clickElement()
  
  #multiple failed attempts of trying to selecting the theme = Loneliness - can't get to work :-(
  ##attempt 1
  webElem &lt;- remDr$findElement(using = 'xpath', value = &quot;//*[@data-shinyjs-resettable-id='themeOPN']&quot;)
  webElem$highlightElement()
  webElem$clickElement()
  
  webElem1 &lt;- remDr$findElement(using = 'xpath', value = &quot;//*[@data-selectable data-value='Loneliness']&quot;)
  webElem1$highlightElement()
  webElem1$clickElement()
  
  ##
  ##attempt 2
  webElem &lt;- remDr$findElement(using = 'xpath', value = &quot;//*[@data-shinyjs-resettable-id='themeOPN']&quot;)
  webElem$highlightElement()
  webElem$clickElement()
  
  webElem2 &lt;- remDr$findElement(using = 'xpath', value = &quot;/html/body/div[1]/div[2]/div/div[8]/div[3]/div[1]/form/div[1]/div/div/div[2]/div/div[2]&quot;)
  webElem2$highlightElement()
  webElem2$clickElement()
  
  ##
  ##attempt 3
  
  webElem &lt;- remDr$findElement(using = 'xpath', value = &quot;//*[@data-shinyjs-resettable-id='themeOPN']&quot;)
  webElem$highlightElement()
  webElem$clickElement()
  
  webElem3 &lt;- remDr$findElement(using = 'xpath', value = &quot;//*[text()='Loneliness']&quot;)
  webElem3$highlightElement()
  webElem3$clickElement()
  
  ##
  ##attempt 4
  
  webElem &lt;- remDr$findElement(using = 'xpath', value = &quot;//*[@data-shinyjs-resettable-id='themeOPN']&quot;)
  webElem$highlightElement()
  webElem$clickElement()
  
  webElem4 &lt;- remDr$findElement(using = 'xpath', &quot;/html/body/div[1]/div[2]/div/div[8]/div[3]/div[1]/form/div[1]/div/div/div[2]/div/[@value = 'Loneliness']&quot;)
  webElem4$highlightElement()
  webElem4$clickElement()
  
  
  ##
  ##attempt 5
  
  webElem &lt;- remDr$findElement(using = 'xpath', value = &quot;//*[@data-shinyjs-resettable-id='themeOPN']&quot;)
  webElem[[2]]$clickElement()
  </code></pre>