如何找到“新建”按钮的选择器?我需要使用交换框架吗?

2024-09-29 19:36:58 发布

您现在位置:Python中文网/ 问答频道 /正文

<div id="crmMasthead" tabindex="-1">
<div id="crmTopBar" class="ms-crm-TopBarContainer ms-crm-TopBarContainerGlobal newNavBarMode">
<div id="crmAppMessageBar" class="crmAppMessageBar" style="display: none; height: 0px;">
<div id="crmRibbonManager" currentribbonelement="commandContainer15" style="height: 62px; display: block; visibility: visible;">
<div id="commandContainer15" style="display: inline;">
<ul class="ms-crm-CommandBar-Menu" role="application">
<li id="ewrb_importfile|NoRelationship|HomePageGrid|Mscrm.HomepageGrid.ewrb_importfile.NewRecord" class="ms-crm-CommandBarItem ms-crm-CommandBar-Menu ms-crm-CommandBar-Button" tabindex="-1" title="New Create a new Import File record." command="ewrb_importfile|NoRelationship|HomePageGrid|Mscrm.NewRecordFromGrid" style="white-space: pre-line; display: inline-block;">
<span class="ms-crm-CommandBar-Button ms-crm-Menu-Label-Hovered" tabindex="-1" style="max-width:200px">
<a class="ms-crm-Menu-Label" tabindex="0" onclick="return false">
<img class="ms-crm-ImageStrip-New_16 ms-crm-commandbar-image16by16" tabindex="-1" src="/_imgs/imagestrips/transparent_spacer.gif" style="vertical-align:top"/>
<span class="ms-crm-CommandBar-Menu" tabindex="-1" style="max-width:150px" command="ewrb_importfile|NoRelationship|HomePageGrid|Mscrm.NewRecordFromGrid"> New </span>
<div class="ms-crm-div-NotVisible"> Create a new Import File record. </div>
</a>
</span>
</li>

Xpath显示如下:

.//*[@id='ewrb_importfile|NoRelationship|HomePageGrid|Mscrm.HomepageGrid.ewrb_importfile.NewRecord']/span/a 

如果我用这个,Selenium不会点击按钮


Tags: dividstyledisplayclassmsmenucrm
1条回答
网友
1楼 · 发布于 2024-09-29 19:36:58

首先尝试从xpath中删除“.”(点)并检查它是否有效。你知道吗

其次,尝试自己编写xpath。对于此节点,请尝试以下操作:

//a[@class="ms-crm-Menu-Label"]

您应该检查您共享的html部分是否在iframe节点中。否则,你应该多分享。对于您共享的当前部分,无法判断它是否在iframe中。你知道吗

此外,检查按钮的可见性也是一个好主意。最后一件事:您是否收到任何错误消息。如果是,请分享。你知道吗

相关问题 更多 >

    热门问题