-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🐛 Bug]: whenever i have to run the test case, i have to restart the container.. #1896
Comments
@changan1111, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
Hi, @changan1111. Either a complete code snippet and URL/HTML (if more than one file is needed, provide a GitHub repo and instructions to run the code), the specific versions used, or a more detailed description to help us understand the issue. Note: If you cannot share your code and URL/HTML, any complete code snippet and URL/HTML that reproduces the issue is good enough. Reply to this issue when all information is provided, thank you. |
package BotAutomationProject.DreamHotelSuite;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.MediaEntityBuilder;
import com.aventstack.extentreports.model.Media;
import com.epam.healenium.SelfHealingDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
import java.net.URL;
import io.github.bonigarcia.wdm.WebDriverManager;
import junit.framework.Assert;
public class FirstTest {
WebDriver driver;
private ExtentTest test;
@BeforeTest
public void setup() {
ExtentReportUtils.initializeExtentReport();
// Create a new test instance
test = ExtentReportUtils.createTest("My Test Chennai");
}
@Test
public void DreamHotelTest1() throws IOException, InterruptedException {
WebDriverManager.chromedriver().setup();
//WebDriver delegate = new ChromeDriver();
ChromeOptions options = new ChromeOptions();
//URL gridUrl = new URL("http://localhost:4444/wd/hub");
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), options);
//driver = SelfHealingDriver.create(delegate);
test.info("Opening the url");
//driver.get("http://localhost:4200");
driver.get("https://www.google.com/");
System.out.println(driver.getTitle());
test.info(driver.getCurrentUrl());
driver.findElement(By.name("q")).sendKeys("Sachin Tendulkar");
driver.findElement(By.name("btnK")).click();
Thread.sleep(5000);
/*SPALoadTimeTestListener.startTimer();
SPALoadTimeTestListener.calculateLoadTime();
driver.findElement(By.xpath("//input[@ng-reflect-name='text']")).clear();
driver.findElement(By.xpath("//input[@ng-reflect-name='text']")).sendKeys("Chennai");
driver.findElement(By.xpath("//button[text()='Search']")).click();
test.info("Search value is Chennai");
SPALoadTimeTestListener.startTimer();
SPALoadTimeTestListener.calculateLoadTime(); ////*[@class='card']/div/div[2]/div[@class='font-superbig']
String reviewcomment=driver.findElement(By.xpath("//*[@class='card']//div[@class='font-superbig']")).getText();
String screenshotPath = takeCaptureScreen(driver); // Capture the screenshot and get its path
//test.pass("Passed", MediaEntityBuilder.createScreenCaptureFromPath(screenshotPath).build());
test.info("review comment is: "+reviewcomment);
Assert.assertEquals("3.1", reviewcomment);
takeCaptureScreen(driver);
driver.findElement(By.xpath("//input[@ng-reflect-name='text']")).clear();
driver.findElement(By.xpath("//input[@ng-reflect-name='text']")).sendKeys("Chennai");
driver.findElement(By.xpath("//*[text()='Search']")).click();
SPALoadTimeTestListener.startTimer();
SPALoadTimeTestListener.calculateLoadTime();
test.info("End of Dream Hotel Test1");*/
}
public static String takeCaptureScreen(WebDriver driver) throws IOException {
driver = ((SelfHealingDriver) driver).getDelegate();
TakesScreenshot screen = ((TakesScreenshot) driver);
File src = screen.getScreenshotAs(OutputType.FILE);
String dest = System.getProperty("user.dir") + "\\"
+ System.currentTimeMillis() + ".png";
System.out.println(dest);
File target = new File(dest);
FileUtils.copyFile(src, target);
return dest; // Return the path of the captured screenshot
}
@AfterTest
public void finalizeReport() {
// Flush the Extent Report after all test cases finish
System.out.println(test.getModel().getLogs());
HashMap<String, String> ExtentLogs = ExtentReportUtils.extractLogs(test.getModel().getLogs());
System.out.println(ExtentLogs.get("LogDetails"));
ExtentReportUtils.flushReport();
driver.close();
// ExtentReportUtils.removeTest();
}
} this is the sample code written.. when I run first time it is working, again if i want to run just in case, i need to restart the container.. without that it is not working.. is this the design for this image? |
A couple of things:
|
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What happened?
I am running the test case eg. after 1st Testcase if i am running again, then it is not running, it is stays on the same screen..
and if I restart container, then again I am able to run the testcase. Is this the behavior? I can not run back to back test cases?
Without restarting the container, i am unable to run the testcase multiple times or multiple test cases..
Is this behavior that after every run I need restart container to proceed to next test case run?
Command used to start Selenium Grid with Docker
docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-chrome
Relevant log output
Operating System
Windows 11
Docker Selenium version (tag)
4.10.0
The text was updated successfully, but these errors were encountered: