Jump to content

Click IE object by text


Recommended Posts

Ahhh, sometimes it is that simple. @Danp2 I finally got the syntax error out of the way - yeeyyy-.

I have changed the code to the following, because I read in the "Help & Support" threat that "contain" would help if you are trying to address multiple elements.

_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//div[contains(@class,'item') and contains(text(),'Noch nicht veröffentlicht')]")
   $NNV = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[contains(@class,'item') and contains(text(),'Noch nicht veröffentlicht')]")
   _WD_ElementAction($sSession, $NNV, 'click')

I am getting this result:

Quote

__WD_Post: URL=HTTP://127.0.0.1:9515/session/cc08fae7919653e59b568dfe72e93cdd/element; $sData={"using":"xpath","value":"//div[contains(@class,'item') and contains(text(),'Noch nicht veröffentlicht')]"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"8397171d-e146-4220-a83b-db1cc03a97f0"}}
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"8397171d-e146-4220-a83b-db1cc03a97f0"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/cc08fae7919653e59b568dfe72e93cdd/element/8397171d-e146-4220-a83b-db1cc03a97f0/click; $sData={"id":"8397171d-e146-4220-a83b-db1cc03a97f0"}
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"element not interactable","message":"element not interactable\n

It makes no sense to me. I was able to click this button with IE, but it seems impossible with the Webdriver. What am I missing? (probably my brain this time😂)

Link to comment
Share on other sites

@_leo_ Since we don't have access to the site, we are limited on how to guide you further. I suspect that you are clicking the wrong element. Chances are that you should be clicking the related "input" element or maybe even the surrounding "label".

Open the browser's developer's tools (F12) and review the source code. Chances are that you see some elements with an "event" marker next to it. You will have to investigate these to determine which one actually needs to be triggered.

Link to comment
Share on other sites

Thanks @Danp2 I got it to work!! The problem was not, that I was interacting with the wrong elements. i figured out, that adding a "sleep" solves the issue. I thought that the _WD_WaitElement would do the job, but I probably misunderstood the functionality of it.

sleep(4000)
   _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//div[contains(@class,'item') and contains(text(),'Noch nicht veröffentlicht')]")
   $NNV = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[contains(@class,'item') and contains(text(),'Noch nicht veröffentlicht')]")
   _WD_ElementAction($sSession, $NNV, 'click')

Anyways: I am going to print the code and put it in a picture frame-hihi-.

Link to comment
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
 Share

×
×
  • Create New...