legend Posted June 1, 2017 Share Posted June 1, 2017 there's multiple classnames called "muted", but I want to click on the first one. Here's what i'm trying to do: #include <IE.au3> ;loads the site and inserts some text Local $oIE = _IECreate("http://www.dba.dk/opret-annonce/#back") Local $oForm = _IEFormGetCollection($oIE, 0) Local $oQuery = _IEFormElementGetCollection($oForm, 1) _IEFormElementSetValue($oQuery, "ur") ;~ _IEFormSubmit($oForm) ;clicks a button Local $oSubmit = _IEGetObjByName($oIE, "Find kategori") _IEAction($oSubmit, "click") ;---------------------------------------------------------- $oElems = _IETagNameGetCollection($oIE, "li") ; get all li tags For $oElem In $oElems ; loop over all elements If StringInStr($oElem.className, "muted") Then ; this is the tag we need $oLink = _IETagNameGetCollection($oIE, "a", 0) ; get the first link inside the element _IEAction($oLink, "click") ; click the link ExitLoop EndIf Next I can't get the last part to work, maybe someone has a suggestion? Link to comment Share on other sites More sharing options...
Danp2 Posted June 1, 2017 Share Posted June 1, 2017 From what I can see, this part is broken Local $oSubmit = _IEGetObjByName($oIE, "Find kategori") _IEAction($oSubmit, "click") but can easily be fixed by replacing with _IEFormSubmit($oForm) Also, this $oLink = _IETagNameGetCollection($oIE, "a", 0) ; get the first link inside the element returns the first link on the page. Perhaps you meant this instead? $oLink = _IETagNameGetCollection($oElem, "a", 0) ; get the first link inside the element Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
legend Posted June 1, 2017 Author Share Posted June 1, 2017 the things is, it can't find the classname: "muted" The url is here: http://www.dba.dk/opret-annonce/# Link to comment Share on other sites More sharing options...
Danp2 Posted June 1, 2017 Share Posted June 1, 2017 This works for me -- #include <IE.au3> ;loads the site and inserts some text Local $oIE = _IECreate("http://www.dba.dk/opret-annonce/#back") Local $oForm = _IEFormGetCollection($oIE, 0) Local $oQuery = _IEFormElementGetCollection($oForm, 1) _IEFormElementSetValue($oQuery, "ur") Sleep(2000) $oElems = _IETagNameGetCollection($oIE, "li") ; get all li tags For $oElem In $oElems ; loop over all elements If StringInStr($oElem.className, "muted") Then ; this is the tag we need ConsoleWrite("found!" & @CRLF) $oLink = _IETagNameGetCollection($oElem, "a", 0) ; get the first link inside the element _IEAction($oLink, "click") ; click the link ExitLoop EndIf Next Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
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