-1

Using Django and LiveServerTest, I am testing this URL:

#template.py
<div id = "id_delete"><a href="/{{ file.pk }}/delete/" onclick="return 
confirm('Are you sure ?')">delete</a></div>

#tests.py
self.selenium.find_element_by_xpath('//*[@id="id_delete"]/a').click()

and I want Selenium to pause to let me click on "cancel" when JavaScript asks 'Are you sure ?' and go on with the following tests.

How can I do that?

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
Brigitte Maillère
  • 847
  • 1
  • 9
  • 27
  • 2
    Possible duplicate of [Click the javascript popup through webdriver](https://stackoverflow.com/questions/8631500/click-the-javascript-popup-through-webdriver) – mrfreester Jan 09 '18 at 04:57
  • 1
    I misread the original question... Do you really want the script to pause so you can manually click? Or do you just want the script to handle the popup? If you want to pause... is a breakpoint ok? Or do you want the end program to always pause in this scenario? – mrfreester Jan 09 '18 at 05:05
  • @JeffC totally agree with you, I always do it. Sometimes you are a very beginner on a new topic and after searching a while you cannot spot the good keywords neither know how to clearly explain your problem. – Brigitte Maillère Jan 09 '18 at 09:25

1 Answers1

0

Thanks @mrfreester, this answer solved my problem : Click the javascript popup through webdriver

I asked how to "let the user confirm" because I was not aware that Webdriver could handle javascript without user interaction.

Thank you for having understood my need better than me.

Stackoverflow suggests my question is perhaps a duplicate. I don't think so : Being a beginner in Django testing I had no idea I had to search a solution using the keyword "webdriver". Perhaps other people will encounter the same situation. This is why I keep my question as not duplicated.

Brigitte Maillère
  • 847
  • 1
  • 9
  • 27