1
votes

I am trying to click on a <a> tag but when I am trying to access it by ID i got an error that says Unable to locate element.

I am using selenium c# in unit test project. the code to make the click is the followining:

IWebdriver.FindElement(By.Id("BUTTON_OPEN_SAVE_btn0_acButton")).Click();

and <a> tag code is the following:

<a id="BUTTON_OPEN_SAVE_btn0_acButton" ct="B" title="New Analysis of Existing Data" st="" href="javascript:void(0);" class="urBtnStd" ocl="sapbi_page.sendCommandArray([['BI_COMMAND_TYPE','LOAD',0],['TARGET_DATA_PROVIDER_REF','DP_1',0],['OPEN_SAVE_DIALOG_LAYOUT','DATAPROVIDER_PERSISTENCY',0]],event);" onkeydown="ur_Button_keypress(event);" onclick="ur_Button_click(event);" style="width:0;width:0;">New Analysis</a>

2

2 Answers

0
votes

Try this:

IWebdriver.FindElement(By.XPath("//a[@class='urBtnStd']")).Click();
0
votes

To click on the button with text as New Analysis you can use the following line of code :

IWebdriver.FindElement(By.XPath("//a[@class='urBtnStd' and [contains(.,'New Analysis')]]")).Click();