Reputation: 1
when i pass 2 different test data in @test annotation and in @afterTest driver.close() i get the connection reset error and 2nd browser instance is closed
public class HomePage extends base {
//WebDriver driver;
@BeforeTest
public void url() throws IOException {
}
@Test(dataProvider="getData")
public void basepagenaviggation(String username,String password,String Text) throws IOException {
driver=initializeDriver();
driver.get("https://www.hackerrank.com/auth/login");
// one way inheritance-- extends
//creating method to that class and invoke methods of it
//landingPage lp=new landingPage(driver);
//lp.login().click();
loginPage lP=new loginPage(driver);
lP.getUserame().sendKeys(username);
lP.getPassword().sendKeys(password);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
System.out.println(Text);
lP.loginButton().click();
}
@AfterTest
public void closeBrowser() {
driver.close();
}
@DataProvider
public Object[][] getData() {
//rows stands for how many different data types test should run
//column stands for how many values for each test
Object[][] data=new Object[2][3];
//0th row
data[0][0]="[email protected]";
data[0][1]="123456";
data[0][2]="dd user";
//1st row
data[1][0]="[email protected]";
data[1][1]="123456";
data[1][2]="ff user";
return data;
}
error
[RemoteTestNG] detected TestNG version 7.5.0
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Starting ChromeDriver 101.0.4951.41 (93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904}) on port 59288 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. May 14, 2022 10:01:04 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C May 14, 2022 10:01:04 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch WARNING: Unable to find an exact match for CDP version 101, so returning the closest version found: 97 May 14, 2022 10:01:04 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch INFO: Found CDP implementation for version 101 of 97 dd user Starting ChromeDriver 101.0.4951.41 (93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904}) on port 53408 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. May 14, 2022 10:01:11 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C May 14, 2022 10:01:11 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch WARNING: Unable to find an exact match for CDP version 101, so returning the closest version found: 97 May 14, 2022 10:01:11 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch INFO: Found CDP implementation for version 101 of 97 ff user May 14, 2022 10:01:27 PM org.openqa.selenium.remote.http.WebSocket$Listener onError WARNING: Connection reset java.net.SocketException: Connection reset at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:367) at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:398) at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:258) at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132) at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:832)
PASSED: basepagenaviggation("[email protected]", "123456", "ff user") PASSED: basepagenaviggation("[email protected]", "123456", "dd user")
Upvotes: 0
Views: 93
Reputation: 41
I had same issue which got resolved by giving .quit(); instead of .close();
My suggestion is to avoid using .close(); just use .quit(); which should close the browser and dispose of the WebDriver.
Upvotes: 0