'How to Invoke Selenium class from clicking Html Button using tomcat
I have three test case in different java file and want to invoke it using tomcat server by clicking html button. This is my html
<form action="case1" method="post">
<input type="submit" id="sele" name="button" value="TestCase1">
<input type="submit" id="sele1" value="TestCase2">
<input type="submit" id="sele2" value="TestCase3">
</form>
After clicking button it will check which button is clicked in servlet and invoke respective class , one button example
String button = req.getParameter("button");
PrintWriter out = res.getWriter();
if ("TestCase1".equals(button)) {
try {
out.println("Started");
Sele s=new Sele();
s.sele();
out.println("Ended");
} catch (InterruptedException e) {
e.printStackTrace();
}
The output screen show Started and Ended but it didnt invoke Selenium class. And Not Showing any error or Exception, My selenium class code
public class Sele{
public void sele() throws InterruptedException, IOException{
System.setProperty("webdriver.chrome.driver","C:/java/jar/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://localhost:8080/first/index2.html");
driver.manage().window().maximize();
But if i Execute this java code in through command prompt it invoke Selenium class
public Remote{
void remote(){
Sele s=new Sele();
s.sele();
}
}
Code work correctly and open chrome as automated for above code but not in server can any one help me out here.....
Solution 1:[1]
In sele class I added debugger Address and open in particular port to see what went wrong and you can able trigger new browser from already opened browser to ren selenium script
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | 12 class video |
