I know this should be simple, I'm just not sure why this is not working! Please help. I have the following code:
RSelenium::startServer()
require(RSelenium)
remDr <- remoteDriver(remoteServerAddr = "localhost"
, port = 4444
, browserName = "safari"
)
remDr$open()
remDr$navigate("http://www.cs.ucr.edu/~mshok002/")
Next, I need to click on the link "Teaching" at the top of the page and I'm stuck here. The html code is here at the following I'm just not sure how to find it using remDr$findElement. How can I search for both the link "Teaching" and html code "Teaching.html"?
<a href="Teaching.html">Teaching</a>
Thanks much
To click a link, we can use the link text locator which matches the text enclosed within the anchor tag. We can also use the partial link text locator which matches the text enclosed within the anchor tag partially. NoSuchElementException is thrown if there is no matching element found by both these locators.
A linkText is used to identify the hyperlinks on a web page. It can be determined with the help of an anchor tag (<a>). In order to create the hyperlinks on a web page, you can use anchor tags followed by the linkText.
We can click a button with Selenium webdriver in Python using the click method. First, we have to identify the button to be clicked with the help of any locators like id, name, class, xpath, tagname or css. Then we have to apply the click method on it. A button in html code is represented by button tagname.
We can click a link by href value with Selenium webdriver. To identify the link with the href attribute we can take the help of the locators xpath or css selector.
I figured out how to do it so I'm posting my answer which may be helpful for others. I came up with two approaches: First:
remDr$navigate("Teaching.html")
Second:
webElem <- remDr$findElement(using = 'css selector',"Teaching")
webElem$clickElement()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With