Mercy Posted March 7, 2018 Posted March 7, 2018 I inspect that Security tab in the webpage .I get the html element below: <td tabindex="-1" align="center" class="infaTabsetSimpleTabSetTop" nowrap="true" valign="middle" onfocus="app_details_browse.$47()">Security</td> If iam using the class name and trying to click the element. Iam getting "found" but cannot click as all the tab contains same class. If iam using the onfocus attribute which is different for every tab and trying to click the element, the element cannot be found. Local $oFound = "" Local $oBtns = _IETagNameGetCollection($oIE, "td") For $oBtn In $oBtns ;If String($oBtn.onfocus) ="app_details_browse.$47()" Then If String($oBtn.classname) = "infaTabsetSimpleTabSetTop" Then $oFound = $oBtn EndIf Next If IsObj($oFound) Then _IEAction ($oFound, "focus") _IEAction ($oFound, "click") MsgBox(16, "Success", "found") Else MsgBox(16, "Failed", "Not found.") EndIf
Danp2 Posted March 7, 2018 Posted March 7, 2018 Have you tried using _IEPropertyGet to retrieve the innertext and then compare to "Security"? Latest Webdriver UDF Release Webdriver Wiki FAQs
Mercy Posted March 8, 2018 Author Posted March 8, 2018 (edited) Added the _IEPropertyGet and got the innertext as "Security" in the message box. So im pointing the right object but it is not clicking the tab. Local $iScreenX = _IEPropertyGet($oFound, "innertext") MsgBox(0,"",$iScreenX) If IsObj($oFound) Then _IEAction ($oFound, "click") MsgBox(16, "Success", "found") Trying with the below code .. it is going into the if statement and displaying the msgbox as clicked but it is not clicking. If String($oFound.innertext) = "Security" Then _IEAction ($oFound, "click") MsgBox(16, "Success", "Clicked") EndIF Edited March 8, 2018 by Mercy
Danp2 Posted March 8, 2018 Posted March 8, 2018 6 hours ago, Mercy said: Trying with the below code .. it is going into the if statement and displaying the msgbox as clicked but it is not clicking. It's difficult to give additional suggestions when the only thing you've shown us is a screen shot. Have you logged into the site prior to running your code? Latest Webdriver UDF Release Webdriver Wiki FAQs
Subz Posted March 8, 2018 Posted March 8, 2018 Can you try the following looking at the actions of the td it only has an OnFocus action, nothing for OnClick, unless they have some other code which is being fired based upon the OnFocus and the Class Name. Hope that makes sense. If $oFound.innertext = "Security" Then _IEAction ($oFound, "focus") MsgBox(16, "Success", "Clicked") EndIF
Mercy Posted March 9, 2018 Author Posted March 9, 2018 8 hours ago, Subz said: Can you try the following looking at the actions of the td it only has an OnFocus action, nothing for OnClick, unless they have some other code which is being fired based upon the OnFocus and the Class Name. Hope that makes sense. If $oFound.innertext = "Security" Then _IEAction ($oFound, "focus") MsgBox(16, "Success", "Clicked") EndIF Yes, tried with this also. the web page is not loading to the page which security tab has to load. And when we do manually, we need to click that tab and not to focus.
Danp2 Posted March 9, 2018 Posted March 9, 2018 Have you tried bringing up the Developer Tools using F12 and examining the events attached to the tab? That's generally the first thing I do when I encounter a situation where the standard _IE* commands aren't working for me. Latest Webdriver UDF Release Webdriver Wiki FAQs
Juvigy Posted March 9, 2018 Posted March 9, 2018 Maybe it needs to receive the Onfocus event before clicking. Try: $oFound.FireEvent("OnFocus")
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now