| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 744 人关注过本帖
标题:【求助】selenium定位不到元素
只看楼主 加入收藏
废物新人
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2022-4-27
收藏
 问题点数:0 回复次数:0 
【求助】selenium定位不到元素
selenium定位不到元素,元素是放在script标签里面的,是JS,一直定位不到,script标签里面的代码如下:

<script id="tpl-topMenuNav" type="text/html">
    <!-- 菜单区 -->
    <div class="topMenuNav lev1 lev" id="topMenuNavContainer" style="width: {{= d.width}}px">
        <ul class="topNavContainer lev1Ul">
        {{# for(var i = 0, len = d.currentNavGroupArray.length; i < len; i++){ }}
            <li class="lev1Li" style="max-width: {{ d.lev1MaxTextWidth }}px;">
                <div class="lev1Title navTitleName" title="{{= d.currentNavGroupArray[i].name.escapeJavascript() }}" onmouseenter="javascript:topNavShowChildAndFixPostion(this,'{{ d.eachLiHeight }}')" onmouseleave="javascript:topNavHideChild(event,this)"{{# if(d.currentNavGroupArray[i].url){ }} onclick="javascript:showMenu('{{_ctxPath + d.currentNavGroupArray[i].url }}','{{ d.currentNavGroupArray[i].id }}','{{ d.currentNavGroupArray[i].target }}','{{ d.currentNavGroupArray[i].resourceCode }}',this)" style="cursor: pointer;"{{# }else{ }} style="cursor: default;" {{#} }}>
                    <div class="navText">{{= d.currentNavGroupArray[i].name.escapeJavascript() }}</div>
                </div>
                {{# if(d.currentNavGroupArray[i]["items"]){ }}
                <div class="lev2 lev" onmouseenter="javascript:topNavShowThisLev(this)" onmouseleave="javascript:topNavHideThisLev(this)">
                    <div class="navScrollUp" onselectstart="return false" onclick="javascript:navScrollUp(this,'{{ d.eachLiHeight }}')"><i class="vportal vp-arrow-up-serif"></i></div>
                    <ul class="lev2Ul">
                        {{# for(var j = 0, _len = d.currentNavGroupArray[i]["items"].length; j < _len; j++){ }}
                        <li class="lev2Li" style="height: {{ d.eachLiHeight }}px;line-height: {{ d.eachLiHeight }}px" id="lev2_{{ d.currentNavGroupArray[i].items[j].id }}">
                            <div id="{{ d.currentNavGroupArray[i].items[j].resourceCode }}" class="lev2Title navTitleName" title="{{= d.currentNavGroupArray[i]['items'][j].name.escapeJavascript() }}" {{# if (d.currentNavGroupArray[i].items[j].url) { }} onclick="javascript:showMenu('{{_ctxPath + d.currentNavGroupArray[i].items[j].url }}','{{ d.currentNavGroupArray[i].items[j].id }}','{{ d.currentNavGroupArray[i].items[j].target }}','{{ d.currentNavGroupArray[i].items[j].resourceCode }}',this)"{{# } }} onmouseenter="javascript:topNavShowChildAndFixPostion(this,'{{ d.eachLiHeight }}')" onmouseleave="javascript:topNavHideChild(event,this)" data-id="{{ d.currentNavGroupArray[i].items[j].id }}">
                                {{# var iconValue = d.currentNavGroupArray[i].items[j].icon; }}
                                {{# if(iconValue && iconValue.indexOf("/fileUpload.do") > -1){ }}
                                <div class="navIcon"><img src="{{ _ctxPath + iconValue + CsrfGuard.getUrlSurffix() }}" /></div>
                                {{#}else if(iconValue && iconValue.indexOf("/seeyon") > -1){ }}
                                <div class="navIcon"><img src="{{ iconValue + CsrfGuard.getUrlSurffix() }}" /></div>
                                {{#}else if(iconValue){ }}
                                <div class="navIcon"><i class="vportal vp-{{ iconValue }}"></i></div>
                                {{# } }}
                                <div class="navText">{{= d.currentNavGroupArray[i].items[j].name.escapeJavascript() }}</div>
                                {{# if(d.currentNavGroupArray[i].items[j].items && d.currentNavGroupArray[i].items[j].items.length > 0){ }}<div class="arrow"><i class="vportal vp-arrow-right-serif"></i></div>{{#} }}
                            </div>
                            {{# if(d.currentNavGroupArray[i].items[j].items){ }}
                            <div class="lev3 lev" onmouseenter="javascript:topNavShowThisLev(this)" onmouseleave="javascript:topNavHideThisLev(this)">
                                <div class="navScrollUp" onselectstart="return false" onclick="javascript:navScrollUp(this,'{{ d.eachLiHeight }}')"><i class="vportal vp-arrow-up-serif"></i></div>
                                <ul class="lev3Ul">
                                    {{# for(var k = 0, __len = d.currentNavGroupArray[i]["items"][j]["items"].length; k < __len; k++){ }}
                                    <li class="lev3Li" style="height: {{ d.eachLiHeight }}px;line-height: {{ d.eachLiHeight }}px">
                                        <div class="lev3Title navTitleName" title="{{= d.currentNavGroupArray[i]['items'][j]['items'][k].name.escapeJavascript() }}" {{# if (d.currentNavGroupArray[i].items[j].items[k].url) { }} onclick="javascript:showMenu('{{_ctxPath + d.currentNavGroupArray[i].items[j].items[k].url }}','{{ d.currentNavGroupArray[i].items[j].items[k].id }}','{{ d.currentNavGroupArray[i].items[j].items[k].target }}','{{ d.currentNavGroupArray[i].items[j].items[k].resourceCode }}',this)"{{# } }} onmouseenter="javascript:topNavShowChildAndFixPostion(this,'{{ d.eachLiHeight }}')" onmouseleave="javascript:topNavHideChild(event,this)"><span class="navText">{{= d.currentNavGroupArray[i]["items"][j]["items"][k].name.escapeJavascript() }}</span></div>
                                        {{# if(d.currentNavGroupArray[i].items[j].items[k].items){ }}
                                            <div class="lev4 lev" onmouseenter="javascript:topNavShowThisLev(this)" onmouseleave="javascript:topNavHideThisLev(this)">
                                                <div class="navScrollUp" onselectstart="return false" onclick="javascript:navScrollUp(this,'{{ d.eachLiHeight }}')"><i class="vportal vp-arrow-up-serif"></i></div>
                                                <ul class="lev4Ul">
                                                    {{# for(var l = 0, ___len = d.currentNavGroupArray[i]["items"][j]["items"][k]["items"].length; l < ___len; l++){ }}
                                                    <li class="lev4Li" style="height: {{ d.eachLiHeight }}px;line-height: {{ d.eachLiHeight }}px">
                                                        <div class="lev4Title navTitleName" title="{{= d.currentNavGroupArray[i]['items'][j]['items'][k]['items'][l].name.escapeJavascript() }}" {{# if (d.currentNavGroupArray[i].items[j].items[k].items[l].url) { }} onclick="javascript:showMenu('{{_ctxPath + d.currentNavGroupArray[i].items[j].items[k].items[l].url }}','{{ d.currentNavGroupArray[i].items[j].items[k].items[l].id }}','{{ d.currentNavGroupArray[i].items[j].items[k].items[l].target }}','{{ d.currentNavGroupArray[i].items[j].items[k].items[l].resourceCode }}',this)"{{# } }} onmouseenter="javascript:topNavShowChildAndFixPostion(this,'{{ d.eachLiHeight }}','{{ d.domId }}')"><span class="navText">{{= d.currentNavGroupArray[i]["items"][j]["items"][k].name.escapeJavascript() }}</span></div>
                                                    </li>
                                                    {{# } }}
                                                </ul>
                                                <div class="navScrollDown" onselectstart="return false" onclick="javascript:navScrollDown(this,'{{ d.eachLiHeight }}')"><i class="vportal vp-arrow-down-serif"></i></div>
                                            </div>
                                            {{# } }}
                                    </li>
                                    {{# } }}
                                </ul>
                                <div class="navScrollDown" onselectstart="return false" onclick="javascript:navScrollDown(this,'{{ d.eachLiHeight }}')"><i class="vportal vp-arrow-down-serif"></i></div>
                            </div>
                            {{# } }}
                        </li>
                        {{# } }}
                    </ul>
                    <div class="navScrollDown" onselectstart="return false" onclick="javascript:navScrollDown(this,'{{ d.eachLiHeight }}')"><i class="vportal vp-arrow-down-serif"></i></div>
                </div>
                {{#} }}
            </li>
            {{# } }}
        </ul>
        <ul class="pageArea">
            <li id="navPrev" class="disabled" onselectstart="return false" title="上一页"><i class="vportal vp-arrow-left-serif"></i></li>
            <li id="navNext" class="disabled" onselectstart="return false" title="下一页"><i class="vportal vp-arrow-right-serif"></i></li>
        </ul>
        <div id="activeSubNav" class="activeSubNav" onmouseenter="javascript:showActiveNavAndParent(event,this)" onmouseleave="javascript:hideActiveNavAndParent(event,this)">
            <div id="activeSubNavInner" class="activeSubNavInner"></div>
        </div>
    </div>
</script>

<!--消息盒子(底部弹出)-->
<script id="tpl-messageBottom" type="text/html">
    <div class="messageBlock" id="messageBlock" onclick="javascript:vPortalMainFrameElements.messageBottom.toggleMsgbox();"><span class="msg_remind"></span><i class="vportal vp-remind"></i></div>
    <div class="messageBottom display_none" id="messageBottom">

        <div class="messageBottomTitle">
            <span>{{$.i18n("message.header.more.set")}}(<label id="sysMsgTotalCount1">0</label>)</span>
            <i class="vportal vp-min right" onclick="javascript:vPortalMainFrameElements.messageBottom.toggleMsgbox();"></i>
        </div>

        <div class="msgTab display_none" id="tab_messageBottomTab">
                <div class="tabMoreDiv"><i class="vportal vp-arrow-down-serif"></i><div class="tabMoreDivIn"><div class="tabMoreDivInC" id="tabMore_messageBottomTab"></div></div></div>
        </div>


        <div class="messageUl" id="messageUl">

        </div>

        <div class="msgSetting">
            <i class="vportal vp-setting margin_r_10" onclick="javascript:vPortalMainFrameElements.messageBottom.showMessageSet('/seeyon/message.do?method=showMessageSetting&fromModel=top');"></i>
            <span class="msgSettingMenu" onclick="javascript:vPortalMainFrameElements.messageBottom.ignoreAllSysMsg();">{{$.i18n('portal.message.ignoreall')}}</span>
            <span class="msgSettingMenu" onclick="javascript:vPortalMainFrameElements.messageBottom.showMoreMessage()">{{$.i18n('portal.message.seeall')}}</span>
        </div>

</div>



<iframe id="playSoundHelper" class="hidden" frameborder="0" height="0" width="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>
</script>

<!-- 首页设置 -->
<script id="tpl-skinSet" type="text/html">
    <div id="skin_set" class="skin_set_contaner display_none">
        <div class="skin_top_bar">
            <div class="skin_top_bar_left">
                {{# for(var i=0;i<d.length;i++){
                    var choosed = "";
                    if(d[i].code=='0'){
                        choosed = "choosed";
                    }
                }}
                    <span id="theme_category_{{d[i].code}}" class="padding_l_5 hand padding_r_5 {{choosed}}" onclick="javascript:vPortalMainFrameElements.skinSet.chooseOperate({{d[i].code}})">{{ $.i18n(d[i].name)}}</span>
                {{# }}}
                <!--<span class="padding_l_5 hand padding_r_5 choosed" onclick="javascript:vPortalMainFrameElements.skinSet.chooseOperate(0)">{{ $.i18n("portal.theme.category.all")}}</span>
                <span class="padding_l_5 hand padding_r_5" onclick="javascript:vPortalMainFrameElements.skinSet.chooseOperate(0)">{{ $.i18n("portal.theme.category.work")}}</span>
                <span class="padding_l_5 hand padding_r_5" onclick="javascript:vPortalMainFrameElements.skinSet.chooseOperate(0)">{{ $.i18n("portal.theme.category.business")}}</span>
                <span class="padding_l_5 hand padding_r_5" onclick="javascript:vPortalMainFrameElements.skinSet.chooseOperate(0)">{{ $.i18n("portal.theme.category.functions")}}</span> -->
                <!-- <span class="padding_l_5 hand padding_r_5 choosed" onclick="javascript:vPortalMainFrameElements.skinSet.chooseOperate(0)">{{ $.i18n("vportal.skinSet.template.label")}}</span> -->
                <!-- <span class="margin_r_5 hand padding_l_5 padding_r_5" onclick="javascript:vPortalMainFrameElements.skinSet.chooseOperate(1)">皮肤</span> -->
            </div>
            <div class="skin_top_bar_right">
                <span class="padding_l_10 margin_r_5 hand padding_r_10" onclick="javascript:vPortalMainFrameElements.skinSet.spaceSet()">{{ $.i18n("menu.personalset.spaceset")}}</span>
                {{# if(!vPortal || !vPortal.navCustomSwitch || vPortal.navCustomSwitch == '1') { }}
                <span class="padding_l_10 margin_r_5 hand padding_r_10" id="navSetId" onclick="javascript:vPortalMainFrameElements.skinSet.configSpaceNav()">{{ $.i18n("vportal.skinSet.nav.label")}}</span>
                {{#}}}
                {{# if(!vPortal || !vPortal.menuCustomSwitch || vPortal.menuCustomSwitch == '1') { }}
                <span class="margin_l_5 margin_r_5 hand padding_l_10 padding_r_10" id="menuSetId" onclick="javascript:vPortalMainFrameElements.skinSet.menusSet()">{{ $.i18n("portal.design.MenuSettings")}}</span>
                {{#}}}
                {{# if(document.getElementById("shortcutNav")){}}
                <span class="margin_l_5 hand padding_l_10 padding_r_10" onclick="javascript:vPortalMainFrameElements.skinSet.quickMenu()">{{ $.i18n("portal.design.QuickSetting")}}</span>
                {{#}}}
                <i onclick="javascript:vPortalMainFrameElements.skinSet.hideSkinPanle();" class="margin_l_20 hand vportal vp-icon vp-close closeSkinSet"></i>
            </div>
        </div>
        <div class="skin_content_tabs" id="skin_content"></div>
    </div>
</script>

这样需要怎么才能定位,刚学的,遇到这种就不会定位了,希望有人指点一下,感谢
搜索更多相关主题的帖子: javascript this onclick class div 
2022-04-28 17:29
快速回复:【求助】selenium定位不到元素
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.062029 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved