请帮助为什么不能点击保存和关闭图片下面?它显示错误,没有这样的元素。
action.MoveToElement(driver.FindElement(By.XPath("//*[@class='ms-crm-Menu-Label']"))).Click().Build().Perform();
driver.FindElement(By.XPath("//*[@class='ms-crm-ImageStrip-Save_16 ms-crm-commandbar-image16by16']/img")).Click();这是HTML。
<li tabindex="-1"
title="Save & Close (ALT+S) Save and close this Lead."
class="ms-crm-CommandBarItem ms-crm-CommandBar-Menu ms-crm-CommandBar-Button"
id="lead|NoRelationship|Form|Mscrm.Form.lead.SaveAndClose" style="display: inline-block; white-space: pre-line;"
command="lead|NoRelationship|Form|Mscrm.SaveAndClosePrimary">
<span tabindex="-1" class="ms-crm-CommandBar-Button ms-crm-Menu-Label"
style="max-width: 200px;">
<a tabindex="0" class="ms-crm-Menu-Label" onclick="return false">
<img tabindex="-1"
class="ms-crm-ImageStrip-SaveAndClose_16 ms-crm-commandbar-image16by16"
style="vertical-align: top;" src="/_imgs/imagestrips/transparent_spacer.gif"></img>
<span tabindex="-1" class="ms-crm-CommandBar-Menu" style="max-width: 150px;"
command="lead|NoRelationship|Form|Mscrm.SaveAndClosePrimary"> Save & Close </span>
<div class="ms-crm-div-NotVisible"> Save and close this Lead. </div>
</a>
</span>
发布于 2017-06-15 04:05:20
Webdriver无法使用您使用的xpath来定位控件。尝试以下几个方面:
driver.FindElement(By.XPath("//li/span/a[@class='ms-crm-Menu-Label']/span[@command='lead|NoRelationship|Form|Mscrm.SaveAndClosePrimary']")).Click();让我知道它是否适合你。
https://stackoverflow.com/questions/44554791
复制相似问题