23

A quick search in brings up some questions like this:

I am doing automation with selenium, I have tried this:

[Some code of a Selenium automation, often with a complicated XPath query, and also often no original HTML source]

And I get this error: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@name='q']"}

Few examples: here, here, here, here and a long etc.

These questions are challenging to manage. First of all, if no original HTML source is provided for us to reproduce the issue, they're plain unanswerable, other than the common troubleshooting tips like "check in the web inspector that the XPath actually works... make sure no one steals focus... etc".

Even in the case the sources are provided and we can reproduce the issue, I still think on how relevant for the community is to dedicate the effort in answering the question. We love to help out, but answers in this questions are only useful to the OP, since it is highly unlikely that anybody else will automate the same webpage (unless it is a very famous website, which isn't usually the case).

I feel like the effort put into answering these questions (which is not an easy task anyway, since it means visiting the website, trying to get an idea of which element OP is trying to locate, checking the location method used actually finds the element, or coming up with an adequate locator for the intended element...) is simply too high for the actual return given to the community. It goes against the so-called long tail philosophy of the community, since these questions will not provide much value to somebody with a similar (not identical) issue.

So, do we need a canonical question for NoSuchElementException and similar errors in Selenium?

While I feel this would be the best option, I'm just unsure on how canonical we can get with an issue that is highly tied to a specific automation. Providing generic troubleshooting tips will not help the most casual user, who still can't see it and may ask anyway for specific help to locate a specific element, potentially challenging duplicate question flags because they don't answer his problem. There are also a couple situations where the situation actually requires a specific answer, some websites do have strange behaviors such as modal dialogs, focus stealing and other problems that would be very hard to describe in the canonical question. This means having a canonical question, while helping most of the users (I would say 90% at least), there would be a handful of questions that would not be answered by the canonical question, and may still be marked as duplicate to the canonical question by somebody not paying enough attention to the specifics of the question.

A potential candidate for canonical answer could be the answer to this question, perhaps adding a few more suggestions from the community, but it is a good starting point.

I would like to hear opinions from other Selenium community users and if they see it from my perspective or maybe it is not such a big deal, and also, in the case a canonical question is not required, how should we deal with these questions.

14
  • 8
  • 14
    This does sound like a situation where a generic canonical is the way out just to be able to swiftly close such low effort zero usefulness questions.
    – Gimby
    Commented Mar 30, 2021 at 10:19
  • 1
    @Gimby no, that would be abusing the system. The correct thing to ask is for a hammer for unclear reason.
    – Braiam
    Commented Mar 30, 2021 at 14:53
  • 7
    @Braiam Why would it be abusing the system, if there was a good canonical describing the issue and very likely providing OP a path for debugging and likely a solution? Commented Mar 30, 2021 at 14:58
  • @CertainPerformance because the OP isn't asking "how to debug program" but "how to fix error". The former are helpful for the later, but they aren't the same question.
    – Braiam
    Commented Mar 30, 2021 at 15:00
  • 4
    A somewhat similar question exists here which is (rightly) an extremely frequent target for questions reporting an error about not finding an element without a MCVE, though it's for JS, not for Selenium. Having something similar for Selenium sounds reasonable Commented Mar 30, 2021 at 15:00
  • 1
    It's either having a canonical question giving some advice, or no answer at all, since it is not worth taking the time to answer a question that will only help a single person, unless you're going for the easy rep. Commented Mar 30, 2021 at 15:01
  • 1
    @Braiam It is food for thought indeed. What makes the situation more clear and what makes it easier to moderate such questions. I think it is easier to get such a question dupe closed than it is to get it closed as unclear. Both things really send the same signal IMO, getting a question closed with a very generic canonical is still the act of saying "Need more? Then explain more!". Either way the OP needs to do more than no effort to get their question reopened.
    – Gimby
    Commented Mar 30, 2021 at 15:41
  • 1
    In some cases, this problem starts as a generic "why doesn't beautifulsoup4 load this dynamic page" question, which, depending on the mood of the answerer, seems to get either a "use this specific REST endpoint I found for you" or "use selenium" as the answer. Surprisingly often the selenium answer seems to spawn the question you're seeing. Commented Mar 30, 2021 at 15:54
  • @Gimby except that the system doesn't cull such questions from the system automagically like the other path does. SE has expresed already that askers are frustrated with duplicate closure, which means "this question has been asked before", not "this info is helpful to you", nor "you need to read this first". For those we have comments.
    – Braiam
    Commented Mar 30, 2021 at 16:47
  • 6
    "potentially challenging duplicate question flags because they don't answer his problem." That's hardly a Selenium-specific issue, it happens with canonical questions in every tag where OP just wants something they can copy-paste rather than having to actually think. Commented Mar 30, 2021 at 18:02
  • There was often value in these questions from seeing the strategies employed to overcome the problem(s) - which is often more than just the OP reported error. As you state, you often have to run the whole process yourself to determine the true nature of the situation. Also true, it is rare now to see any new techniques being employed however. Perhaps the value is renewed when technologies evolve. Indeed a challenge.
    – QHarr
    Commented Mar 31, 2021 at 17:59
  • 1
    @QHarr but if there is value in seeing the strategies employed, won't it be better to have them all summarized into a canonical question, in a generic manner, so that any user with this problem can have a handful of options rather than sticking to whichever strategy the answerer gave him? Commented Mar 31, 2021 at 19:06
  • Somehow now we have Are canonical dupes a waste of everyone's time?, bringing more uncertainity for this question -ha, ha.- Commented Mar 31, 2021 at 19:08

0

You must log in to answer this question.

Browse other questions tagged .