0

On the Web page, I have 3 buttons with a link image in a table.I want to click on Image. But I could not locate the image with button as "send"

Here is HTML code for image embeded in table:

<a class="ctl00_C_S_Z_ctrlActionToolbar_Menu1_1" href="javascript: ValidateSendMessage()>
<img src="ShmControls/ShmImages/SHM_Send_Trans.png" alt="Send Message" style="border-style:none;vertical-align:middle;>"Send" /a>

Let me know, how I can locate this button on the web page?

I tried with all the below options to locate image element

IWebElement Send = driver.FindElement(By.XPath("a[@href= 'javascript: ValidateSendMessage()')]"));
IWebElement Send = driver.FindElement(By.XPath("//img[contains(src,'ShmControls/ShmImages/SHM_Send_Trans.png')]"));
IWebElement Send = driver.FindElement(By.XPath("//*@id='ctl00_C_S_Z_ctrlActionToolbar_Menu1']"));        
IWebElement Send = driver.FindElement(By.LinkText("ShmControls/ShmImages/SHM_Send_Trans.png"));  
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

To click on the WebElement with text as Send you can use either of the following Locator Strategies:

  • Using CssSelector:

    IWebElement Send = driver.FindElement(By.CssSelector("a[class*='ctrlActionToolbar_Menu'][href*='ValidateSendMessage']"));
    
  • Using XPath:

    IWebElement Send = driver.FindElement(By.XPath("//a[contains(@class, 'ctrlActionToolbar_Menu') and contains(@href, 'ValidateSendMessage')]"));
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352