需要点击“新建”按钮。我如何处理它,因为它没有显示/可见?这是有关的代码 -
<li tabindex="-1" class="ms-crm-CommandBarItem ms-crm-CommandBar-Menu ms-crm-CommandBar-Button" title="NewCreate a new Account record." id="account|NoRelationship|HomePageGrid|Mscrm.HomepageGrid.account.NewRecord" command="account|NoRelationship|HomePageGrid|Mscrm.NewRecordFromGrid" style="white-space: pre-line; display: inline-block;"><span tabindex="-1" class="ms-crm-Menu-Label ms-crm-CommandBar-Button" 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" src="/_imgs/imagestrips/transparent_spacer.gif" style="vertical-align:top" alt="New"> <span tabindex="-1" class="ms-crm-CommandBar-Menu" style="max-width:150px" command="account|NoRelationship|HomePageGrid|Mscrm.NewRecordFromGrid"> New </span> </a> </span> </li>
答案 0 :(得分:1)
因为它是隐藏的,单击该元素的唯一方法是执行javascript
并使用javascript执行程序执行单击。
我假设您使用的是Selenium java绑定,因为您没有提到过。
//Find the element to click on.
//Selenium will find the element without any issue
//since it is present in the DOM
//I assumed you want to click on the <code>span</code> with text New
//since there is no actual button
WebElement element = driver.findElement(By.cssSelector("[title='NewCreate a new Account record.']>span>a>span"));
JavascriptExecutor jsExecutor = (JavascriptExecutor)driver;
jsExecutor.executeScript("arguments[0].click();", element);