I am trying to log in to this page: https://www.optionslam.com/accounts/login/ using the code on this post as a starting point, Scrape password-protected website in R
I have been able to populate the login fields, but cannot click on the log in button. If you look at the source of the page, the class of login is "red-button"
<input type="submit" value="Log in" class="red-button"/>
However, there is another form at the top of the page that also uses the same class, and the clickElement() command is clicking on it. Reading the RSelenium documentation, I can't find a way to either search for the 2nd instance of this class or look it up based on type="submit" or value="Log In".
Here is my code:
library(RSelenium)
pJS <- phantom() # start phantomjs
appURL <- 'https://www.optionslam.com/accounts/login/'
remDr <- remoteDriver(browserName = "phantomjs")
remDr$open()
remDr$navigate(appURL)
remDr$findElement("id", "id_username")$sendKeysToElement(list("user"))
remDr$findElement("id", "id_password")$sendKeysToElement(list("pass"))
remDr$findElement("class name", "red-button")$clickElement()
Thank you for your help.