Questions tagged [nosuchelementexception]

Use this tag if your problem is caused by or primarily involves a NoSuchElementException in Java.

The NoSuchElementException is a RuntimeException thrown by the nextElement method of an Enumeration to indicate that there are no more elements in the enumeration.

It is also thrown by:

  • the various next* methods (nextInt, nextFloat, nextLine,...) of the Scanner class when input is exhausted;
  • the get method of the Java 8 Optional class when a value is not present;
  • the methods firstElement and lastElement in the Vector class when there are no elements;
  • the methods firstKey and lastKey in the TreeMap class when there are no keys;
  • the methods getFirst, getLast, removeFirst and removeLast in LinkedList when there are no elements;

and other collections.

573 questions
3
votes
2 answers

Selenium WebDriver with Java NoSuchElementException timeout

I have a problem with the timeout time of the NoSuchElementException, it seem to be 30 seconds by default and I want to shorten it down. So I wrote something like this: WebDriverWait wait = new WebDriverWait(driver, 10); WebElement element =…
3
votes
2 answers

Type mismatch error in method with generic return (Why do I have to do a cast to the generic type in this method, but not in similar ones?)

I am getting the following error from a method in which I need a generic return type: Description Resource Path Location Type Type mismatch: cannot convert from PageTypeOne to P SecuredPage.java I can get rid of the error by casting the…
Selena
  • 2,208
  • 8
  • 29
  • 49
2
votes
1 answer

Python Selenium - find table elements and get their values - but new page loads for a second and then for unknown reason return to previus page

when I click on an image manually, the new page loads, and the new page is stable. When I click via selenium in python, the new page loads for a few seconds and then returns to the previous page automatically for an unknown reason, so I can't…
2
votes
2 answers

Selenium error 'Message: no such element: Unable to locate element'

I get this error when trying to get the price of the product: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element But the thing is that I am searching by XPath from the Inspect HTML panel. SO how…
densol96
  • 49
  • 3
2
votes
0 answers

No connection could be made because the target machine actively refused it in selenium python when i use try except block

I want the browser shoud't shut down when he can't find class for this i use try except block try-except is running but my browser is closing when try line come for execution but print line is executing in cmd from selenium import webdriver import…
2
votes
5 answers

How to find the find the div element using Selenium and Python

Selenium is unable to find an element on a webpage, here is the python code element = driver.find_element(By.CLASS_NAME, "_13NKt copyable-text selectable-text") Here is an image of the element it is supposed to find, class highlighted And here is…
2
votes
1 answer

When should NoSuchFieldException be used versus NoSuchElementException?

Aside from NoSuchFieldException being a checked exception, where NoSuchElementException is not, what are the differences between the two exceptions? When should one be used as opposed to the other? Specifically, I am working on an OOP representation…
2
votes
2 answers

Selenium Unable to locate Element (Partial Text Link)

I am new to Selenium and I try to click a link on a second page (after the login page). The login part works and the browser goes to the next page however on the next page it raises an exception: This is my Traceback: Traceback (most recent call…
2
votes
1 answer

How to click on the See all button using Selenium and Python

This script with Selenium in Python 3 helps me to scrape data from a page by clicking the see all button, but it stopped working and I do not know the cause. Could you help me with the code? from selenium import webdriver from…
2
votes
1 answer

Selenium - Why NoSuchElementException happens in the second for loop iteration?

I'm trying to loop over a list of web elements matching a div tag. The first loop goes well, but the second one throws a NoSuchElementException. Here is a minimal example of my code: for div in…
ezzeddin
  • 499
  • 2
  • 5
  • 25
2
votes
2 answers

NoSuchElementException infinite loop vs. pmd DD-anomaly

I'm kinda new to programming and very new to gradle and the pmd-plugin, so please have mercy. If the user enters a number, scanner.nextLine() will throw a NoSuchElementException in every iteration thus creating an infinite loop. public class Console…
2
votes
2 answers

Why do I get noSuchElementException when using listIterator.add()?

Without further delay, I will post my code straight away. It is very simple so you shouldn't find any problems understanding it. My idea is to add color after it found "blue" using listIterator. Apparently there is something wrong here. public class…
Stefan
  • 969
  • 6
  • 9
2
votes
1 answer

Probable impact of implicit wait removal

In our Selenium automated tests, we've implicit and explicit waits. As per Jim Evan's thought https://stackoverflow.com/a/15174978/1471417, they should not be mixed. Hence planning to remove implicit wait. For our tests, whenever we interact with an…
2
votes
1 answer

No such element for an element inside of a dialog

When I try to click an element hosted inside of a dialog is returning NoSuch element exeption error returned I've tried using active element and also switch to default content but no success. This portion of code has no iframes in the middle so a…
2
votes
2 answers

java.util.NoSuchElementException: No value present even though we use stream

I am new to java, i am running a local server (jar) and trying to hit an API endpoint. All data is correct, and I am getting below : java.util.NoSuchElementException: No value present The execption seems to be occuring on the below line in the code…
1 2
3
38 39