Thursday, 12 September 2013

Finding element using Selenium Web Driver in C#

Finding element using Selenium Web Driver in C#

So I've been working learning how to use Selenium in C# to do some
automated testing for a project. However, I've hit a roadblock on this
one. I have been trying to figure out of way to click the following link
on this webpage.
Here is what I'm trying to target:
<A class='PortalLink'
HREF="https://mywebsite.com/myprograms/launchprogram.jsp?"
onClick="setUser('login','password');"><span>MyProgram</span></A>
Searching by ClassName hasn't turned up anything. Although there are
multiples, I just wanted to see if I could detect the presence of them.
By.ClassName("PortalLink")
I tried a href based search using CssSelector, but this failed as well.
By.CssSelector("[href*='https://mywebsite.com/myprograms/launchprogram.jsp?']")
Lastly, I tried to use XPath and search by class and span content, but
this failed to find the link as well.
By.XPath("//A[contains(@class,'PortalLink') and span[text()='MyProgram']]")))
The webpage in question contains 2 frames which I've tried both.
I'm waiting 200 seconds before timing out. What am I doing incorrectly?
Thanks in advance for any help!

No comments:

Post a Comment