Question

I'm not sure how to use nativeClickAt() method to click at an arbitrar location.

In the spynner class, the doc said :

"""Click on an arbitrar location of the browser.
@param where: where to click (QPoint)
@param real: if not true coordinates are relative to the window instead
    of the screen
@timeout seconds: seconds to wait after click"""

I have had searched QT doc to figure out what is a QPoint object. So it seems to be x, y coordinates.

What I tried so far :

import spynner
from PyQt4 import QtCore

browser = spynner.Browser(
    embed_jquery = True,
    debug_level = spynner.DEBUG
)

(...)

place = QtCore.QPoint(311,443)
print place # PyQt4.QtCore.QPoint(311, 443)
browser.nativeClickAt(place, 3, real=True)

But when I run the script, I get a segfault error.

Any help will be very appreciate.

Was it helpful?

Solution

We have discussed offlist of this non public script.

What we have done:

  • You must have an ui to send raw click events : browser.show()
  • You must not hide the window when the script executes or it will click in the void -> segfault.

OTHER TIPS

Native click heavily depends on the state of the browser and its frames that can become unanavailable when you will be firing the event, causing the segfault.

As it depends really on the use case, the simplest would be to have a reproducible test !

Nevertheless i will check that the method behaves correctly since the 2.0 upgrade.

Be also sure to have the latest spynner !

Also, to trace spynner errors when segfaults happens, the best is always to have it go with gdb or any debugger. And yes, i have had segfaults by the past always resolved by changing my code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top