Actions action = new Actions(driver); IWebElement we = driver.FindElement(By.XPath(".//*[@class='ms-crm-CommandBar-Button ms-crm-Menu-Label']"));
爲什麼我不能在這段代碼中點擊這個元素?
action.MoveToElement(driver.FindElement(By.XPath(".//*[@class='ms-crm-CommandBar-Button ms-crm-Menu-Label-Hovered']"))).Click().Build().Perform();
期望元素如下:
< 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-New_16 ms-crm-commandbar-image16by16" style="vertical-align: top;" src="/_imgs/imagestrips/transparent_spacer.gif"> <span tabindex = "-1" class="ms-crm-CommandBar-Menu" [enter image description here][1]style="max-width: 150px;" command="lead|NoRelationship|HomePageGrid|Mscrm.NewRecordFromGrid"> New </span> <div class="ms-crm-div-NotVisible"> Create a new Lead record. </div>
</a> </span>
注意,此類"ms-crm-CommandBar-Button ms-crm-Menu-Label"
原來是"ms-crm-CommandBar-Button ms-crm-Menu-Label-Hovered"
當鼠標懸停。
非常感謝。
錯誤的複製和粘貼。其實,沒有「。」盈方// –
跨度下也有 ... New Create a new Lead record. –
你好 - 歡迎來到SO--請閱讀「如何提問」之前:https://stackoverflow.com/help/how-to-ask – Cadburry