我正在网上寻找帮助我解决这个问题的东西。我学会了如何制作一个arrayList,但我想知道如何让它成为可接受的用户输入。我的意思是我希望用户输入他的号码。 这就是我所拥有的:
org.openqa.selenium.WebDriverException: Could not convert screenshot to base64 -
Error: Unable to load canvas into base64 string -
[Exception... "Failure" nsresult: "0x80004005 (NS_ERROR_FAILURE)"
location: "JS frame :: file:///C:/Users/c38151/AppData/Local/Temp/anonymous7393315997897601641webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js :: fxdriver.screenshot.toBase64 :: line 10440" data: no]
Command duration or timeout: 1.13 seconds
Build info: version: '2.53.0',
revision: '35ae25b1534ae328c771e0856c93e187490ca824',
time: '2016-03-15 10:43:46'
System info: host: 'W7E1384109', ip: '172.26.31.114',
os.name: 'Windows 7',
os.arch: 'amd64',
os.version: '6.1',
java.version: '1.8.0_74'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=45.2.0, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: e48040a1-37c2-4767-a46f-acaf697dc8c4
我现在拥有的是我放在那里的数字。非常感谢任何帮助。
提前致谢。
答案 0 :(得分:0)
EndPoint = "https://us.api.concursolutions.com/oauth2/v0/otp"
Payload = "client_id=" & consumerKey & "&client_secret=" & consumerSecret & "&channel_handle=" & Email & "&channel_type=email"
Payload = Payload & "&link=" & link & "&name=" & name & "&company=" & company
Dim xmlhttp
Set xmlhttp = Createobject("MSXML2.ServerXMLHTTP.6.0")
'Get error message with or without the next 3 lines
XMLhttp.setOption(2) = 13056
strCert = "Friendly Name"
XMLhttp.setOption(3)= "LOCAL_MACHINE\My\" & strCert
XMLhttp.Open "POST",EndPoint,false
XMLhttp.setRequestHeader "User-Agent","HTTP/1.1"
XMLhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"
XMLhttp.setRequestHeader "Accept", "application/json"
XMLhttp.setRequestHeader "Host", "us.api.concursolutions.com"
XMLhttp.setRequestHeader "Connection", "close"
XMLhttp.setRequestHeader "Content-Length", "437"
XMLhttp.send Payload
答案 1 :(得分:0)
这两行代码是将用户输入到ArrayList中所必需的:
int n = input.nextInt();
myList.add(n);
所以完整的代码会显示为:
public class MyClass {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
ArrayList<Integer> myList=new ArrayList<Integer>(10);
System.out.println("Enter your number:");
int n = input.nextInt();
myList.add(n);
myList.add(416355);
myList.add(21212);
for(int x : myList)
System.out.println(x);
System.out.println("Size="+myList.size());
}
}
您可能会发现这有用:How can I get the user input in Java?
答案 2 :(得分:0)
import java.util.ArrayList;
import java.util.Scanner;
public class MyClass {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
ArrayList<Integer> myList = new ArrayList<Integer>(10);
int totalNumbers = 10;
for (int i = 0; i < totalNumbers; i++) {
System.out.println("ENTER Element to add into list");
Scanner element = new Scanner(System.in);
int ele = (element .nextInt());
myList.add(ele);
}
for (int x : myList)
System.out.println(x);
System.out.println("Size=" + myList.size());
}
}
So the full code would read:
答案 3 :(得分:0)
据我所知,您希望捕获用户数据并将其保存到数组中;对于每个输入元素,您需要创建一个变量:
import java.util.ArrayList;
import java.util.Scanner;
public class MyClass {
public static void main(String[] args) {
ArrayList<Integer> myList=new ArrayList<Integer>(10); enter code here
System.out.println("Enter your number:");
Scanner input=new Scanner(System.in);
int a = input.nextInt();
int b = input.nextInt();
myList.add(a);
myList.add(b);
for(int x : myList)
System.out.println(x);
System.out.println("Size="+myList.size());
}
}
答案 4 :(得分:0)
import java.util.ArrayList;
import java.util.Scanner;
public class Average
{
public static void main(String[] args)
{
ArrayList<Double> numbers = new ArrayList<Double>();
Scanner in = new Scanner(System.in);
System.out.println("Please enter a list of numbers: ");
while (in.hasNextDouble())
{
double input = in.nextDouble();
numbers.add(input);
}
if (numbers.size() == 0)
{
System.out.println("No average.");
}
else
{
double total = 0;
for (double element : numbers)
{
total = total + element;
}
double average = total / numbers.size();
System.out.println("The average is: " + average);
}
}