Selenium单击没有ClassName / ID的按钮

时间:2017-03-20 07:34:43

标签: c# selenium browser automation

我正在开发浏览器自动化,但我无法点击按钮。我试过这个程序:

webDriver.FindElement(By.XPath("//*[@id='uploadForm: fileup']/div[1]/button[1]")).Click();
webDriver.ElementBul(By.("Dosya Yükle"), gecisScreen).Click();

HTML

<a type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-left ui-fileupload-upload" role="button" aria-disabled="true">
<span class="ui-button-icon-left ui-icon ui-c ui-icon-arrowreturnthick-1-n"></span><span class="ui-button-text ui-c">Dosya Yükle</span>
</a>

如下:

see Image

1 个答案:

答案 0 :(得分:0)

试试这个:

foreach (IWebElement item in webDriver.ElementleriBul(By.XPath("//button//span"), gecisScreen))
{
     if (item.Text.In("Yükle"))
     {
          item.Tikla();
          break;
     }
}