0

This is a quite challenging question I believe.

My target webpage is click here

You see that there is a button with the text "Jouw zoekertje GRATIS PLAATSEN" with orange background. If you click on this link on your regular browser, it goes to "http://www2.kapaza.be/nl/ai". That part is fine.

Now I do the same thing on QWebView in Qt. I think it doesn't matter if it is Qt or any other environment. I believe that it will behave the same. What happens is that, when I load this link to my QWebView, it just doesn't load anything. Something keeps loading but nothing visible comes out. I am thinking that this is a sort of protection of the website. In my application, I need to click on this link programmatically. I have done similar thing so far many times for other links or buttons but non of them works on this target link. Could anyone tell me what could be the problem?

First I thought that it is because of cookies. I enabled them on my software but still the same.

Dundar
  • 1,311
  • 1
  • 14
  • 25

1 Answers1

0

From my experience with automation\simulation using QWebView - no site is bulletproof if you do it correctly. Especially when its about simulating clicks, scrolls etc (client side actions).

So, I just tried doing what you tried to do and it worked, page loaded, button clicked and redirected.

This is the code that did the trick:

def tracker(self):
  return self.webView.page().currentFrame().documentElement()

qweb.load('http://www.kapaza.be/nl/index.htm')
button = qweb.tracker().findFirst('a[class="btn  homepage_btn"]')
button.evaluateJavaScript('this.click();')

As I see no apparent problem, it might just be you made a small mistake, so trying the code above might help.

If that dosn't help, here are a couple of things to consider:

  • Proxy - if you're connected via a proxy with QWebView, some pages might not load or never stop loading. Try to turn it off or switch it (turn it off to be sure...).
  • Settings - it might have something to do with tampering with the settings of QWebView. I would try adding: webView.settings().setAttribute(QWebSettings.AutoLoadImages, False)
  • Try to call "reload" after a couple of seconds. It worked for me a couple of times:
...
wait(10)
webView.reload()

All in all - this is just one of the things that sometimes happen with QWebView. You just need to get familiar with the workarounds, learn to identify these events and handle them effectively. Bottom line is - I can't find anything specifically wrong with the page - which is good news! you can do whatever you want with it. Try the steps I've mentioned and if that doesn't work, please submit relevant parts of your code.

Good luck

Matanoga
  • 101
  • 5