1

I am doing automation using selenium Webdriver in c#.So in my application, after clicking on one link, there is frame opened on top of main browser window So i am able to read text on that frame, in short i can switch to that frame. Frame having many hyperlink, and i have to click on hyperlink named "Add/Change Admin Message". But i uses below code to click on link but it is scrolling down the frame in IE browser so click action is not performed.But its works fine in chrome browser.

Driver.FindElement(By.XPath("//a[contains(text(),'"+"Add/Change Admin Message"+"')]")).Click();

I have tried with xpath,cssselector,classname,Id,linktext,partial link text but no luck. Below is the DOM for that link, please help me .. Add/Change Admin Message

1 Answer 1

0

First, you need to switch to the frame where the link is:

Driver.SwitchTo().Frame("frame name or id");

Then, you can locate the link by partial link text:

Driver.FindElement(By.PartialLinkText("Add/Change Admin Message"));

With IE it is often something magical you should do, try clicking the link via javascript:

IWebElement link = Driver.FindElement(By.PartialLinkText("Add/Change Admin Message"));

IJavaScriptExecutor js = Driver as IJavaScriptExecutor;
js.ExecuteScript("arguments[0].click();", link);
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you very much ...got exact solution
why we have used arguments[0] .....can we use arguments[2]...I mean i didn't get significance of arguments[0]...Could you explain in brief please
@simond there could be multiple parameters passed into the ExecuteScript(), we are using arguments[0] since we are passing a single argument link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.