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
Bhupesh
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()
来源:https://stackoverflow.com/questions/29908679/how-to-clickelement-and-open-the-link-in-the-same-tab-not-in-a-new-window