I want to click on the menu. My code: Click text=账户管理.
F12 can see:
error screenshot:
How should I resolve this error? (I am sure the timeout I set is sufficient)
I want to click on the menu. My code: Click text=账户管理.
F12 can see:
error screenshot:
How should I resolve this error? (I am sure the timeout I set is sufficient)
Hi Hugo,
Click text=账户管理
Is probably selecting the <span> inside the <li>which might not be clickable, so you might need to target the <li> element instead, fortunately it appears to have has the same text in the mdlabel attribute, so I would try something like:
Click li[mdlabel='账户管理']
Dave.
I found that the target is inside the frame id=mainWorkArea . So I modified the code to:
Click id=mainWorkArea >>> li[mdlabel=账户管理]
still the same error
I think that for attributes, you need to use always the @.
li[@mdlabel='账户管理']
About, the iframe, if using SeleniumLibrary, before iteracting with elements, you should select the frame:
Select Frame mainWorkArea
Are you using Selenium Library or Browser Library? That syntax only works with Browser Library.
If that’s not working maybe you need to check if there are multiple frames?
Also you can test your css selectors in dev tools (click any element and press CTRL+F, then enter your css selector in the find box. I’ll admit I’ve never tried double byte characters in a css or xpath selector before, so maybe that could be a problem, could be worth searching if there are any known issues with double byte characters in selectors?
If I understand/remember correctly no @ for css selectors, only for xpath, but i get them mixed up too.
If you are using Browser Library, I think you could also try it like this:
Click id=mainWorkArea >>> css=li[mdlabel='账户管理']
or
Click id=mainWorkArea >>> xpath=//li[@mdlabel='账户管理']
and in case there’s more than one match for id=mainWorkArea you could try:
Click css=iframe[id='mainWorkArea'] >>> css=li[mdlabel='账户管理']
If all that fails can you try running it with only robot (i.e. outside your IDE/editor) and check the log.html to see what error the library is giving, maybe it’s finding multiple matches and that’s why the keyword is timing out, actually this is best case scenario as then it’s just a matter of refining the selector to be more specific and find only 1 match
Another thought, in the keyword before are you opening the menu / sub menu that contains this item? do you need to add a wait for the element to exist/fully load before clicking it? running checking the robot log.html file should have a screenshot when it failed, if so check if the menu item is in the screenshot, if not you may need to add a wait step like Wait For Elements State
dear all
I finally found the reason for the failure: because my target was within a two-layer iframe. All previous attempts did not take into account the second-layer iframe. So I corrected it to:Click id=mainWorkArea >>> id=ifrmMain >>> li[mdlabel=账户管理]