Three browser windows are launched but all Login details are entered in single browser window. In the other two browser windows login data are not entered and the test gets failed.
It occurs for thread count greater than one.
Following are the Debugging approaches
- Extracted Jar file works well with Jmeter if the thread count is 1.
- Code works fine when launched from IDE
IDE Used: Eclipse
Project Build: Using Maven Plugin
My Test Class (Main Class)
package test.myproject.com;
import org.junit.After;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
import org.junit.Test;
import org.junit.runner.JUnitCore;
import com.myproject.baseclass.TestBase;
import com.myproject.elements.HomePage;
import com.myproject.elements.OrganisationPage;
import com.myproject.elements.SideMenu;
import com.myproject.util.Helper;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestLoginPage extends TestBase {
HomePage homepage;
SideMenu sidemenu;
OrganisationPage organisationpage;
public TestLoginPage(){
super();
}
@Before
public void BrowserSetup() {
intialization();
}
//@Test
public void MakeLogin() throws InterruptedException {
homepage=new HomePage();
System.out.println(homepage.GetBuildVersion());
Thread.sleep(2000);
homepage.EnterEmail("[email protected]");
homepage.EnterPassword("*****");
homepage.PerformLogin();
System.out.println(driver.getTitle());
}
@Test
public void CreateProject() throws InterruptedException {
MakeLogin();
sidemenu=new SideMenu();
sidemenu.administartion_click();
sidemenu.organisation_click();
organisationpage=new OrganisationPage();
organisationpage.org_setting_click();
sidemenu.org_user_click();
organisationpage.create_button_click();
organisationpage.enter_fullname("loadautomationtest"+Helper.generate_string());
organisationpage.enter_username("loadautomationtest"+Helper.generate_string());
organisationpage.enter_emailid("loadautomationtest"+Helper.generate_string()+"@gmail.com");
organisationpage.click_create();
}
@After
public void TearDown() {
driver.close();
}
public static void main(String[] args) {
//JUnitCore junit = new JUnitCore();
//junit.addListener(new TextListener(System.out));
//Result result = junit.run(TestLoginPage.class);
JUnitCore.main("test.myproject.com.TestLoginPage");
}
}
Class will be declared in Testbase.java class
package com.myproject.baseclass;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
public class TestBase {
public Properties prop;
public FileInputStream file;
public static WebDriver driver;
public static WebDriverWait wait;
public TestBase() {
try {
prop = new Properties();
file = new FileInputStream("Z:/myproject/assets/property/myproject.properties");
prop.load(file);
//data=new ArrayList<String>();
} catch (Exception e) {
e.printStackTrace();
}
}
public void intialization() {
if (prop.getProperty("browser").contentEquals("chrome")) {
System.setProperty("webdriver.chrome.driver",new File("Z:/myproject/assets/driver/chromedriver.exe").getAbsolutePath());
driver = new ChromeDriver();
} else {
System.out.println("No browser found");
}
try {
driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get(prop.getProperty("url"));
} catch (Exception e) {
e.printStackTrace();
System.out.println("Alert Site seems very slow!!!! Please increase the page load time out in util class");
driver.close();
System.exit(0);
}
}
}