nosuchelementexception

Scanner - java.util.NoSuchElementException

吃可爱长大的小学妹 提交于 2019-12-05 00:35:35
问题 Does anyone see a problem with this? First input works fine, but after the first loop, it doesn't ask to enter a value again. How do I fix this? int value; while(true) { Scanner scan = new Scanner(System.in); System.out.println("Enter a value"); try { value = scan.nextInt(); System.out.println("value provided is: " + value); scan.nextLine(); // consumes "\n" character in buffer } catch(InputMismatchException e) // outputs error message if value provided is not an integer { System.out.println(

org.openqa.selenium.NoSuchElementException: no such element

怎甘沉沦 提交于 2019-12-04 22:43:33
问题 Running Selenium WebDriver 2.37.1 I'm receiving an intermittent problem when running a test and receive the following error: org.openqa.selenium.NoSuchElementException: no such element Sometimes the test will pass, most of the time it will fail. Below is the stacktrace: org.openqa.selenium.NoSuchElementException: no such element (Session info: chrome=31.0.1650.57) (Driver info: chromedriver=2.6.232923,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace

Handle the NoSuchElementException in Fluent Wait

早过忘川 提交于 2019-12-04 14:15:41
I know that in terms of waiting for web element that isn't in the DOM yet, the most efficient is a fluent wait. So my question is: Is there a way to handle and catch the NoSuchElementException or any exception that fluent wait might throw because the element is not existing? I need to have a boolean method wherein it will give me result whether the element is found or not. This method is quite popular on the web. public void waitForElement(WebDriver driver, final By locator){ Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) .withTimeout(60, TimeUnit.SECONDS) .pollingEvery(2, TimeUnit

Scanner - java.util.NoSuchElementException

假如想象 提交于 2019-12-03 16:05:43
Does anyone see a problem with this? First input works fine, but after the first loop, it doesn't ask to enter a value again. How do I fix this? int value; while(true) { Scanner scan = new Scanner(System.in); System.out.println("Enter a value"); try { value = scan.nextInt(); System.out.println("value provided is: " + value); scan.nextLine(); // consumes "\n" character in buffer } catch(InputMismatchException e) // outputs error message if value provided is not an integer { System.out.println("Incorrect input type. Try again."); continue; // restarts while loop to allow for re-entering of a

org.openqa.selenium.NoSuchElementException: no such element

限于喜欢 提交于 2019-12-03 14:51:10
Running Selenium WebDriver 2.37.1 I'm receiving an intermittent problem when running a test and receive the following error: org.openqa.selenium.NoSuchElementException: no such element Sometimes the test will pass, most of the time it will fail. Below is the stacktrace: org.openqa.selenium.NoSuchElementException: no such element (Session info: chrome=31.0.1650.57) (Driver info: chromedriver=2.6.232923,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 10.04 seconds For documentation on this error, please visit: http

Spark Scala - java.util.NoSuchElementException & Data Cleaning

不想你离开。 提交于 2019-12-01 17:59:27
I have had a similar problem before , but I am looking for a generalizable answer. I am using spark-corenlp to get Sentiment scores on e-mails. Sometimes, sentiment() crashes on some input (maybe it's too long, maybe it had an unexpected character). It does not tell me it crashes on some instances, and just returns the Column sentiment('email) . Thus, when I try to show() beyond a certain point or save() my data frame, I get a java.util.NoSuchElementException because sentiment() must have returned nothing at that row. My initial code is loading the data, and applying sentiment() as shown in

Scanner NoSuchElementException when calling .next() method

陌路散爱 提交于 2019-12-01 14:19:02
In Java, I'm getting this Exception: Exception in thread "main" java.util.NoSuchElementException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source) at com.reading.text.Activity3.readFile(Activity3.java:22) at com.reading.text.Activity3.main(Activity3.java:10) From this Java code: public static void main(String args[]) { readFile("C:/Users/forsakendoll/Desktop/boom.txt"); } public static void readFile(String path) { Scanner file = null; try { file = new Scanner(new File (path)); } catch (FileNotFoundException e) { e.printStackTrace(); } finally { while (file

java.util.NoSuchElementException using iterator in java

戏子无情 提交于 2019-11-30 07:25:57
问题 I'm trying to iterate through a list using the iterator over my list of Logs. The goal is to search for a logs which contains the same phonenumber, type and date as the new log However, I get a java.util.NoSuchElementException in my conditional statement. Does anyone know what might cause the problem? My code public void addLog(String phonenumber, String type, long date, int incoming, int outgoing) { //Check if log exists or else create it. Log newLog = new Log(phonenumber, type, date,

Why is this code getting a Java NoSuchElement exception?

杀马特。学长 韩版系。学妹 提交于 2019-11-29 15:28:55
I have traced through this code and can't figure out how to fix it. When running the code why wouldn't the user be prompted for input rather than Java determining that there is no input? Error trace below. import java.util.*; public class SortAsInserted { public static void main(String[] args) { int array_size = GetArraySize(); //System.out.println(array_size); String[] myArray = new String[array_size]; for (int i = 0; i < array_size; i++){ String next_string = GetNextString(); System.out.println(next_string); } } //public static String[] SortInsert(String nextString){ //} public static int

java.util.NoSuchElementException using iterator in java

我只是一个虾纸丫 提交于 2019-11-29 03:43:06
I'm trying to iterate through a list using the iterator over my list of Logs. The goal is to search for a logs which contains the same phonenumber, type and date as the new log However, I get a java.util.NoSuchElementException in my conditional statement. Does anyone know what might cause the problem? My code public void addLog(String phonenumber, String type, long date, int incoming, int outgoing) { //Check if log exists or else create it. Log newLog = new Log(phonenumber, type, date, incoming, outgoing); //Log exists Boolean notExist = false; //Iterator loop Iterator<Log> iterator = logs