Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在selenium中单击表中的图像_Javascript_Selenium_Selenium Webdriver_Xpath_Css Selectors - Fatal编程技术网

Javascript 如何在selenium中单击表中的图像

Javascript 如何在selenium中单击表中的图像,javascript,selenium,selenium-webdriver,xpath,css-selectors,Javascript,Selenium,Selenium Webdriver,Xpath,Css Selectors,在网页上,我有3个按钮,在表中有一个链接图像。我想点击图像。但我找不到按钮为“发送”的图像 以下是嵌入到表中的图像的HTML代码: <a class="ctl00_C_S_Z_ctrlActionToolbar_Menu1_1" href="javascript: ValidateSendMessage()> <img src="ShmControls/ShmImages/SHM_Send_Trans.png" alt=&quo

在网页上,我有3个按钮,在表中有一个链接图像。我想点击图像。但我找不到按钮为“发送”的图像

以下是嵌入到表中的图像的HTML代码:

<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>
要单击文本为发送的,您可以使用以下任一选项:

  • 使用CssSelector:

  • 使用XPath:

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"));  
IWebElement Send = driver.FindElement(By.CssSelector("a[class*='ctrlActionToolbar_Menu'][href*='ValidateSendMessage']"));
IWebElement Send = driver.FindElement(By.XPath("//a[contains(@class, 'ctrlActionToolbar_Menu') and contains(@href, 'ValidateSendMessage')]"));