Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I found NodeId ,how can i click it #5

Closed
loveyuxiao opened this issue Aug 21, 2017 · 2 comments
Closed

I found NodeId ,how can i click it #5

loveyuxiao opened this issue Aug 21, 2017 · 2 comments

Comments

@loveyuxiao
Copy link

loveyuxiao commented Aug 21, 2017

    eh = ChromeEventHandler(self.Tab, self.SearchURL)
    self.Tab.Network.responseReceived = eh.response_Received
    self.Tab.Network.requestIntercepted = eh.request_intercepted
    self.Tab.Network.enable()
    self.Tab.Network.setRequestInterceptionEnabled(enabled=True)
    self.Tab.DOM.enable()
    self.Tab.DOM.getDocument()
    element = self.Tab.DOM.performSearch(query='xpath',includeUserAgentShadowDOM=True)
    print(element )
    element__count = int(element.get('resultCount'))
    element__search_id = elemen.get('searchId')
    getSearchResults = self.Tab.DOM.getSearchResults(searchId= element__search_id, fromIndex=0,toIndex=element__count)
  print( getSearchResults)
   nodeId=NodeIds[X]

output:
performSearch={"searchId": "14340.339", "resultCount": 1}
getSearchResults={"nodeIds": [127]}
NodeIds=[127]

now, how can i use the element(by nodeId) click method?
thx

@loveyuxiao
Copy link
Author

I find the way:
resolveNode = self.Tab.DOM.resolveNode(nodeId=NodeIds[0])
RemoteObjectId = resolveNode.get('object').get("objectId")
self.Tab.Runtime.callFunctionOn(objectId=RemoteObjectId, functionDeclaration='(function() { this.click(); })')

@fate0 fate0 closed this as completed May 7, 2019
@TimeAshore
Copy link

@loveyuxiao hi~, thank you for your notes.
I am researching the click. How do you locate the element and click it?
Can you give a complete example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants