2

I have the following html element in my webpage:

<a target="PARENT" href="/bin-din/WebOb/mom.ko/6/wo/asaksdaksjd
/5.1.5.5.33.23.23">View Data Set</a>

I use the following command in Rselenium to find that tag:

webElem<-remDr$findElement(using = 'xpath',"/html/body/div/table/tbody/tr/td/table[2]
/tbody/tr/tbody/tr/td/font/a[1]")

Then I use the following command to click on the link:

webElem$clickElement()

Now the link opens in a new page, probably because the html tag includes target="PARENT". How can I open that link in the same tab which I am in remDr? Any suggestions? Thanks

Mohammad
  • 1,078
  • 2
  • 18
  • 39

1 Answers1

3

First you need to clear target attribute with a blank by injecting javascript in your web element.

Then you can sclick on it and it will open link in same tab. the code somehow look like

webElem<-remDr$findElement(using = 'xpath',"/html/body/div/table/tbody/tr/td/table[2]/tbody/tr/tbody/tr/td/font/a[1]")
remDr$executeScript("arguments[0].setAttribute('target', arguments[1]);", list(webElem, ""));
webElem$clickElement()
jdharrison
  • 30,085
  • 4
  • 77
  • 89
Bhupesh
  • 211
  • 1
  • 7