简体   繁体   中英

Press a button based on action

I would like to press a button which have in button tags this option:

<div aria-controllers="my-list"> Press for more information </div>

Which call from R selenium should I use?

This is what I tried:

webElem1 <- remDr$findElement(using = 'aria-controllers', value = 'my-list')
webElem1$sendKeysToElement(list('R', key = 'enter'))

Also if I use this I receive the following error:

webElem <- remDr$findElement(using = 'aria-controllers', value = "my-list")
Error in match.arg(using) : 
  'arg' should be one of “xpath”, “css selector”, “id”, “name”, “tag name”, “class name”, “link text”, “partial link text”

I don't know R but I think what you need is

webElem1 <- remDr$findElement(using = 'css selector', value = 'div[aria-controllers="my-list"]')

The first argument is the type of locator, that's why you got the error listing all the locator types like 'id', 'css selector', etc. I chose a CSS selector because I think that best matches the way you are trying to locate the element.

The second argument is the locator itself. In this case, the CSS selector.

You probably should spend some time looking at the documentation.

https://cran.r-project.org/web/packages/RSelenium/vignettes/RSelenium-basics.html#search-using-css-selectors

https://www.rdocumentation.org/packages/seleniumPipes/versions/0.3.7/topics/findElement

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM