Jump to content
Sign in to follow this  
CC_Mu

How to locate the item correctly, same id/name in different div

Recommended Posts

CC_Mu

Hey All,

I have a widget selection dropdown box as below, which I need to select different option.

1.thumb.png.1eaae560049742fc02459797ecf371bb.png

What I am trying to do is select one option in each "Division" and "Status", but I have trouble to uniquely find what I want because this two dropdown list have the same id, same name in different <div>, source code is below:

2.thumb.png.e7147d4df2f1f892e35ea8d9d22ef5e5.png

 

You may see the two red underline code almost the same except "Console_Widget_Nm" and "Console_Widget_Set_List_Key", and my current code is as below. 

Call ("download")

Func download ()

Local $oInputs = _IETagNameGetCollection($oIE, "portal$Widget")

For $oInput In $oInputs
   If String($oInput.widgetName="xxx_Division") Then
        _IEFormElementOptionSelect("portal$Widget", "L")
        ExitLoop
    EndIf
Next



EndFunc

The result of the script above is nothing happen.

I know there is a similar solution to use java, but I am really know nothing about java, so I wonder if there is a easier solution to pick the right item I want. Thank you so much for your time and help! 

BTW, I can not share the website because it is a company internal link, and I block some sensitive information in the screenshot but it shouldn't affect anything. Thank you again!

 

 

Share this post


Link to post
Share on other sites
Danp2
8 minutes ago, CC_Mu said:

The result of the script above is nothing happen.

Help us help you. Next time, please post the HTML in a code block (use the <> icon) instead of a picture.

Also, showing us the contents of the Scite output window would help if there are any issues with your code, such as --

_IEFormElementOptionSelect("portal$Widget", "L")

This command probably threw an error. It likely should be this instead --

_IEFormElementOptionSelect($oInput, "L")

Share this post


Link to post
Share on other sites
CC_Mu
<!-- Report Console starts-->
<div id='consoleTitleBar' class="row performane-eval-header-top performance-eval-pages-top"><div class="col-xs-10 col-sm-4 col-lg-7 console-wrap"><a href="#" class="rpm-console-trigger return-false" title="Console" data-behavior="popover" data-target="consolePop"><span style="background:transparent url(/Contents/images/icon-sprites.png) -36px -3px no-repeat;"></span></a><!-- console popover --><div id="consolePop" class="twpopover popper-content hide console-pop"><div class="pop-content " id="Portal_Console"><form id="console-form" method="post" class="form-horizontal console-form" novalidate ><input type="hidden" id="Widget_Lst_Txt" name="Widget_Lst_Txt" ><div><span></span><span></span></div><form id="Portal_Console" name="Portal_Console" class="form-horizontal console-form" style="; display:block"><div class="pop-header" style="height:58px;"><button type="button" class="close" title="Close" data-dismiss="close"><span class="fa fa-times"></span><span class="sr-only">Close</span></button><div class="pop-title">List Report</div></div><div class="pop-body"><div id="consoleError" class="error-wrapper" 
                                        style="margin:15px;display:none;"><span id = "consoleErr" class="error-msg" 
                                        style="width:100%;text-align:center;"></span></div><div class="pop-footer" style="box-shadow: none; padding: 0px;height:58px;">
                    <input class="btn btn-primary portal_submitConsole" type="button" id="portal_submitConsole" value="Display Results" style="margin-right:-0.4%;">
                    <input class="btn btn-default portal_resetConsole cancel" type="button" id="portal_resetConsole" value="Reset All">
                </div><div class="row"><div class="col-sm-12 col-lg-12"><div class="form-group row required"><label class="col-sm-12 col-lg-4 control-label" for="Widget">Division:</label><div class="col-sm-12 col-lg-8"><select name="portal$Widget" id="portal$Widget" Depend_Update_Console_Widget_Key="-1" Console_Widget_Type_Cd="Select" Console_Widget_Nm="RMD_Division" Console_Widget_Set_List_Key="8311" Use_Key_Flg="Y" Required_Flg="Y" Console_Widget_Def_Val_Txt="T" class="form-control" Console_Widget_Display_Txt="Division:" Legacy_Console_Widget_Id="" Depend_Update_Console_Widget_Field_Nm="" Console_Widget_Key="519" Cascade_Widget_Depend_Cnt="4" Console_Widget_General_Session_Flg="N" Alternate_Legacy_Console_Widget_Id="" Has_Def_Val_Flg="Y">
    <option value=""></option>
    <option selected="selected" value="T">Toyota</option>
    <option value="L">Lexus</option>
</select></div></div><div class="form-group row required"><label class="col-sm-12 col-lg-4 control-label" for="Widget">Status:</label><div class="col-sm-12 col-lg-8"><select name="portal$Widget" id="portal$Widget" Depend_Update_Console_Widget_Key="-1" Console_Widget_Type_Cd="Select" Console_Widget_Nm="Status_Type" Console_Widget_Set_List_Key="8312" Use_Key_Flg="Y" Required_Flg="Y" Console_Widget_Def_Val_Txt="" class="form-control" Console_Widget_Display_Txt="Status:" Legacy_Console_Widget_Id="" Depend_Update_Console_Widget_Field_Nm="" Console_Widget_Key="532" Cascade_Widget_Depend_Cnt="0" Console_Widget_General_Session_Flg="Y" Alternate_Legacy_Console_Widget_Id="" Has_Def_Val_Flg="N">
    <option value=""></option>
    <option value="Active Only">Active Only</option>
    <option value="Terminated Only">Terminated Only</option>
    <option value="All (Active &amp; Terminated)">All (Active &amp; Terminated)</option>
</select></div></div></div><div class="col-sm-12 col-lg-12"></div><div class="col-sm-12 col-lg-12"></div></div><div class="row"><div><div style=""></div></div><div><div style=""></div></div><div><div style=""></div></div></div><div class="row"><div class="col-sm-12 col-lg-12"></div><div class="col-sm-12 col-lg-12"></div><div class="col-sm-12 col-lg-12"></div></div><div class="row"><div><div style=""></div></div><div><div style=""></div></div><div><div style=""></div></div></div></div><div class="pop-footer"><input class="btn btn-primary portal_submitConsole" type="button" id="portal_submitConsole" value="Display Results"></input><input class="btn btn-default cancel portal_resetConsole" type="button" id="portal_resetConsole" value="Reset All"></input></div></form><div style="; display:none"></div></form></div></div><!-- /console popover  --><h2 class="console-bar-text">Loading Console...</h2></div></div>                <!-- Report Console ends -->

 

Edited by JLogan3o13

Share this post


Link to post
Share on other sites
JLogan3o13

@CC_Mu in the future, no need to quote every single response, just hit reply. Otherwise the thread quickly becomes impossible to read.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
CC_Mu
10 minutes ago, Danp2 said:

@CC_Mu Did you try modifying the code as indicated?

I tried, still not working. So I modified my code as below, I successfully select the option for the "Division" now, but fail to select anything for the 2nd dropdown.  Any idea or thoughts?

Call ("download")

Func download ()

$tags = _IETagNameGetCollection($oIE, "select")

For $tag in $tags
    Local $innerText = $tag.GetAttribute("Console_Widget_Nm")
    If $innerText = "RMD_Division" Then
       Local $sMyString = _IEGetObjById($oIE, "portal$Widget")
       _IEFormElementOptionSelect($sMyString, "L")

      ElseIf $innerText = "Status_Type" Then
       Local $sMyString = _IEGetObjById($oIE, "portal$Widget")
       _IEFormElementOptionSelect($sMyString, "Active Only")
    EndIf
 Next


EndFunc

 

Share this post


Link to post
Share on other sites
Danp2

Yes, it looks like you are trying to retrieve the object by ID when you've already proven that this won't work because there are more than one with that ID. Plus, you already have a reference to the object from _IETagNameGetCollection.

Try running the following and let me know if it works --

Call ("download")

Func download ()
Local $innerText 
Local $tags = _IETagNameGetCollection($oIE, "select")

For $tag in $tags
    $innerText = $tag.GetAttribute("Console_Widget_Nm")
    
    If $innerText = "RMD_Division" Then
       _IEFormElementOptionSelect($tag, "L")
    ElseIf $innerText = "Status_Type" Then
       _IEFormElementOptionSelect($tag, "Active Only")
    EndIf
Next

EndFunc

 

Share this post


Link to post
Share on other sites
CC_Mu

@Danp2 It works perfectly!

Thank you so much for your help!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.