0

Hey guys I am trying to click on an element called practitioner access on my company's web site and I have tried looking up documentation on stack over flow and have not figured out how to do this exactly I need help. What I am trying to do is click on the practitioner access popup/drop down and I have not been able to find the code to do it. Please see epic at the bottom:

enter image description here This is how far I have gotten so far but protractor cant find the element

var pracaccess = element(by.xpath("//contains(@onclick, 'Practitioner Access')"))
pracaccess.click();
browser.sleep(10000);

I have tried to use these site to try and help myself but I can't piece it together. Any help would be appreciated. I am new to xpath as well.


new info to possibly help: Here is a more expanded view

enter image description here

Also this is what it looks like in vb-script but its basically the same any suggestions?

Browser("ADP_2").Page("ADP_3").Link("html tag:=A","innertext:=Practitioner Access").WaitProperty "visible",True,30000
        Browser("ADP_2").Page("ADP_3").Link("html tag:=A","innertext:=Practitioner Access").Object.Click
Jonathan
  • 395
  • 2
  • 8
  • 25

2 Answers2

2

This XPath expression would look for a tag with the contains tag name, which does not exist. Instead, you've actually meant:

//a[contains(@onclick, 'Practitioner Access')]

Or, there is a nicer way to locate an a element by the link text:

element(by.linkText("Practitioner Access"))
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
0

The answer by alecxe is correct but if you want it to be as xpath:

element(by.xpath('//a[text()="Practitioner Access"]'));
andriyze
  • 464
  • 3
  • 7
  • Hey I tried this and for some reason protractor is saying cant find Practitioner Access and other suggestions. i tried linktext and xpath – Jonathan Dec 06 '17 at 14:40
  • Okay this is my fault this actually works my problem was i need to allow time for the Practitioner Access drop-down to become visible so i did browser.sleep 2000 and it was able to click it. thanks. – Jonathan Dec 06 '17 at 15:42