Java Flood IO-Selenium脚本-无法在Intelij中运行示例Selenium脚本,请继续获取输入字符串Null
我正在本地Intelij中尝试从flood.io运行SeleniumWebDriver示例脚本。但我不断地得到一个错误: 对于输入字符串:“null” 我希望能够运行它,然后更改代码并将其上载到flood.io,这样我就可以在那里运行负载测试和功能性selenium测试 有什么帮助吗 错误日志:Java Flood IO-Selenium脚本-无法在Intelij中运行示例Selenium脚本,请继续获取输入字符串Null,java,selenium-webdriver,ui-automation,load-testing,flood-element,Java,Selenium Webdriver,Ui Automation,Load Testing,Flood Element,我正在本地Intelij中尝试从flood.io运行SeleniumWebDriver示例脚本。但我不断地得到一个错误: 对于输入字符串:“null” 我希望能够运行它,然后更改代码并将其上载到flood.io,这样我就可以在那里运行负载测试和功能性selenium测试 有什么帮助吗 错误日志: C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\bin\java.exe "-java
C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\bin\java.exe "-javaagent:C:\Users\sshiekh\AppData\Local\JetBrains\IntelliJ IDEA Community Edition 2020.3.1\lib\idea_rt.jar=58719:C:\Users\sshiekh\AppData\Local\JetBrains\IntelliJ IDEA Community Edition 2020.3.1\bin" -Dfile.encoding=UTF-8 -classpath C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\charsets.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\ext\access-bridge-64.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\ext\cldrdata.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\ext\dnsns.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\ext\jaccess.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\ext\localedata.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\ext\nashorn.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\ext\sunec.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\ext\sunjce_provider.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\ext\sunmscapi.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\ext\sunpkcs11.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\ext\zipfs.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\jce.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\jfr.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\jsse.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\management-agent.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\resources.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86_64\jre\lib\rt.jar;C:\TestData\demo-selenium\out\test\demo-selenium;C:\TestData\demo-selenium\out\production\demo-selenium;C:\TestData\demo-selenium\test\custom.jar;C:\TestData\demo-selenium\lib\json-simple-1.1.1.jar;C:\TestData\demo-selenium\lib\selenium-server-standalone-3.11.0.jar ChallengeChrome
Exception in thread "main" java.net.MalformedURLException: For input string: "null"
at java.net.URL.<init>(URL.java:645)
at java.net.URL.<init>(URL.java:508)
at java.net.URL.<init>(URL.java:457)
at ChallengeChrome.main(ChallengeChrome.java:33)
Caused by: java.lang.NumberFormatException: For input string: "null"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at java.net.URLStreamHandler.parseURL(URLStreamHandler.java:222)
at java.net.URL.<init>(URL.java:640)
... 3 more
Process finished with exit code 1
import java.net.URL;
import java.util.concurrent.TimeUnit;
import java.util.List;
import java.util.Random;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.Select;
import io.flood.selenium.FloodSump;
public class ChallengeChrome {
public static void main(String[] args) throws Exception {
int iterations = 0;
// Create a new instance of the html unit driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
WebDriver driver =new RemoteWebDriver
(new URL("http://" +
System.getenv("WEBDRIVER_HOST") +
":" +
System.getenv("WEBDRIVER_PORT")
+ "/wd/hub"),
DesiredCapabilities.chrome());
JavascriptExecutor js = (JavascriptExecutor)driver;
// Create a new instance of the Flood IO agent
FloodSump flood = new FloodSump();
// Inform Flood IO the test has started
flood.started();
// It's up to you to control test duration / iterations programatically.
while( iterations < 1000 ) {
try {
System.out.println("Starting iteration " + String.valueOf(iterations));
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
// And now use this to visit the target site
driver.get("https://jriz.io/");
System.out.println("DEBUG - Navigate to main site at https://jriz.io");
// Log a passed transaction in Flood IO
flood.passed_transaction(driver, "The Flood Store - Home");
//select the accessories section
driver.findElement(By.cssSelector("img[alt='Accessories']")).click();
System.out.println("DEBUG - Click Accessories category on the main site");
flood.passed_transaction(driver, "The Flood Store - Accessories");
//add item to cart
Random r = new java.util.Random();
List <WebElement> links = driver.findElements(By.cssSelector("a[class='button product_type_simple add_to_cart_button ajax_add_to_cart']"));
WebElement randomElement = links.get(r.nextInt(links.size()));
int linkListCount = links.size();
System.out.println("Total Number of link count on page = " + linkListCount);
randomElement.click();
flood.passed_transaction(driver, "The Flood Store - Add Item to Cart");
//Go to your cart
driver.get("http://jriz.io/cart/");
flood.passed_transaction(driver, "The Flood Store - View Cart");
// Good idea to introduce some form of pacing / think time into your scripts
Thread.sleep(2000);
iterations++;
} catch (WebDriverException e) {
// Log a webdriver exception in flood
flood.webdriver_exception(driver, e);
} catch(InterruptedException e) {
Thread.currentThread().interrupt();
String[] lines = e.getMessage().split("\\r?\\n");
System.err.println("Browser terminated early: " + lines[0]);
} catch(Exception e) {
String[] lines = e.getMessage().split("\\r?\\n");
System.err.println("Other exception: " + lines[0]);
} finally {
iterations++;
}
}
driver.quit();
// Inform Flood IO the test has finished
flood.finished();
}
}
C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\bin\java.exe“-javaagent:C:\Users\sshiekh\AppData\Local\JetBrains\IntelliJ IDEA社区版2020.3.1\lib\IDEA\rt.jar=58719:C:\Users\sshiekh\AppData\Local\JetBrains\IntelliJ IDEA社区版2020.3.1\bin”-Dfile.encoding=UTF-8-classpath C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\charsets.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\ext\access-bridge-64.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\ext\cldrdata.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\ext\dnsns.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\ext\jaccess.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\ext\localedata.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\ext\nashorn.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\ext\sunec.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\ext\sunjce\u provider.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\ext\sunmsapi.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\ext\sunpkcs11.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\ext\zipfs.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\jce.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\jfr.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\jsse.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\management-agent.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\resources.jar;C:\TestData\java-1.8.0-openjdk-1.8.0.282-1.b08.dev.redhat.windows.x86\u 64\jre\lib\rt.jar;C:\TestData\demo selenium\out\test\demo selenium;C:\TestData\demo selenium\out\production\demo selenium;C:\TestData\demo selenium\test\custom.jar;C:\TestData\demo selenium\lib\json-simple-1.1.1.jar;C:\TestData\demo selenium\lib\selenium-server-standalone-3.11.0.jar ChallengeChrome
线程“main”java.net.MalformedURLException中的异常:对于输入字符串:“null”
位于java.net.URL。(URL.java:645)
位于java.net.URL。(URL.java:508)
在java.net.URL.(URL.java:457)
main(ChallengeChrome.java:33)
原因:java.lang.NumberFormatException:对于输入字符串:“null”
位于java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
在java.lang.Integer.parseInt(Integer.java:580)处
在java.lang.Integer.parseInt(Integer.java:615)
位于java.net.URLStreamHandler.parseURL(URLStreamHandler.java:222)
在java.net.URL.(URL.java:640)
... 3个以上
进程已完成,退出代码为1
导入java.net.URL;
导入java.util.concurrent.TimeUnit;
导入java.util.List;
导入java.util.Random;
导入org.openqa.selenium.By;
导入org.openqa.selenium.WebDriver;
导入org.openqa.selenium.WebElement;
导入org.openqa.selenium.WebDriverException;
导入org.openqa.selenium.JavascriptExecutor;
导入org.openqa.selenium.remote.Augmenter;
导入org.openqa.selenium.remote.DesiredCapabilities;
导入org.openqa.selenium.remote.RemoteWebDriver;
导入org.openqa.selenium.support.ui.Select;
导入io.flood.selenium.floodshall;
公开课挑战赛罗马{
公共静态void main(字符串[]args)引发异常{
int迭代次数=0;
//创建html单元驱动程序的新实例
//请注意,代码的其余部分依赖于接口,
//而不是执行。
WebDriver=新的RemoteWebDriver
(新URL(“http://”)+
System.getenv(“WEBDRIVER\u HOST”)+
":" +
System.getenv(“WEBDRIVER\u端口”)
+“/wd/hub”),
DesiredCapabilities.chrome());
JavascriptExecutor js=(JavascriptExecutor)驱动程序;
//创建泛洪IO代理的新实例
泛洪池洪水=新泛洪池();
//通知Flood IO测试已开始
flood.start();
//由您以编程方式控制测试持续时间/迭代。
而(迭代次数<1000次){
试一试{
System.out.println(“开始迭代”+String.valueOf(迭代));
driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
//现在用这个来访问目标站点
驱动程序。获取(“https://jriz.io/");
System.out.println(“调试-导航到主站点https://jriz.io");
//在泛洪IO中记录已传递的事务
flood.passed_事务(驱动程序,“flood Store-Home”);
//选择附件部分
driver.findelelement(通过.cssSelector(“img[alt='Accessories']))。单击();
System.out.println(“调试-单击主站点上的附件类别”);
flood.passed_交易(驱动程序,“flood商店-配件”);
//将项目添加到购物车
Random r=newjava.util.Random();
列表链接=driver.findelelements(由.cssSelector(“一个[按钮产品类型简单添加到购物车按钮ajax添加到购物车]));
WebElement randomElement=links.get(r.nextInt(links.size());
int linkListCount=links.size();
System.out.println(“链接公司总数
System.setProperty("PATH-TO-YOUR-CHROMEDRIVER");
driver = new ChromeDriver();