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
1
vote
1 answer

Unable to locate element - selenium webdriver python

So I tried to click a button using selenium webdriver in Python. It didn't find the element (in this case a class name), even with enough time to load the element. I got this error: selenium.common.exceptions.NoSuchElementException: Message: no such…
1
vote
1 answer

HTML Selenium Python click on href link

I would like to write a python code where he clicks on the href link. Screenshot of HTML: This is what I am currently having in Python, but it does not work. tables = browser.find_elements_by_xpath('//*[@id="notice"]') for table in tables: …
1
vote
1 answer

How to solve the problem to find least prime number from 1 to 100 and if there is better than this code please kindly update it

I was trying to get Smallest Prime Number(p) by dividing it with set of Distinct (n) Natural Numbers where (q) is the Least Natural Number and the Remainder should be q. Constraints are 1
Tahir
  • 21
  • 6
1
vote
1 answer

java.util.NoSuchElementException while executing junit Testrunner

Error I am getting is: java.util.NoSuchElementException while running junit test. Here is full error from console in eclipse: java.util.NoSuchElementException at java.base/java.util.ArrayList$Itr.next(ArrayList.java:970) at…
1
vote
1 answer

Exception in thread "main" java.util.NoSuchElementException When trying to get String input

In my java code when i am trying to get input as String So Scanner.next() and when i run it Exception in thread "main" java.util.NoSuchElementException this is my code import java.util.Scanner; import java.io.FileNotFoundException; import…
user17668707
1
vote
1 answer

java.util.NoSuchElementException error on multiple while statements

Screenshot of error message Getting this error when I run my code, note that it finds a problem at line 37, but I cannot figure out what it is. Running the first iteration of the scanner method (for input 1) worked fine, and yielded the proper…
Kimchar
  • 11
  • 3
1
vote
1 answer

Firefox headless not working as expected on azure devops raising NoSuchElementException

I'm currently facing an issue trying to run a selenium web automation with firefox(headless) on azure devops, I have the same browser version installed on the windows agent but still I get errors. It works fine for Chrome on Azure and also locally…
1
vote
1 answer

How can I prevent java.util.Scanner from throwing NoSuchElementException when reading from System.in?

I'm attempting to ask the user for a double value, using Scanner.nextDouble(); but I'm getting a NoSuchElementException before I have a chance to type anything. From what I can see in the documentation, this means that Scanner is at the end of the…
1
vote
2 answers

What does Backtrace: Ordinal0 [0x00723AB3+2505395] in stack trace error means while using Selenium and ChromeDriver

I'm relatively new to coding and kinda unfamiliar with stacktrace errors. I have been given this error, but im not sure which part of my code do i fix? Did the error come up because of a NoSuchElementException, or was it due to a timeout error? I…
1
vote
1 answer

java No Such Element Exception when trying to get input

I'm trying to get user input in a loop but it crashes on the second iteration of the while. I get input once but it crashes on the second time calling getInput(), I know for a fact that the first iteration is done…
yftach
  • 31
  • 2
1
vote
1 answer

Selenium checking isDisplayed equals false throws NoSuchElementException

I am getting NoSuchElementException when I check for isDisplayed() equals false for an element. Here is my code: XYZpage.java: public WebElement cancelButton() { return driver.findElement(By.cssSelector(".cancelButton"));…
Zeus
  • 166
  • 1
  • 2
  • 14
1
vote
0 answers

Junit test, NoSuchElementException by Scanner

I had one main method and i need test it. I had two test methods, if I start them separately - all worked. But if I start test all class - got error on second method. Main method: public boolean run() { for (int i = 0; i < REPEAT_COUNT + 1;…
Xa3uK
  • 21
  • 3
1
vote
1 answer

how to login into to a multiple website url using selenium python

read the URL list and enter the ID/Password. By URL, input form has different xpaths. read url and check xpath to input id/pw, but the error occurred. I also want to know what optimization is. ''' def csv_reader(url_obj): reader =…
1
vote
0 answers

Java - Getting 'Exception in thread "main" java.util.NoSuchElementException' error for Scanner

This is my code: I am trying to make a function that allows a user to return to the menu once they have finished with the program. However, I keep getting the 'NoSuchElement' error whenever I try to run the code. import…
1
vote
0 answers

HtmlUnit throws error "java.util.NoSuchElementException" on page load

I try to load the page using HtmlUnit, select the city "Белая Церковь" and see the availability of the drug in pharmacies, but even at the initial stage, when loading the page, I get an error java.util.NoSuchElementException. When I set the…