I am working on contacts creation page in www.salesforce.com developer login account. Anybody can create a free developer login account and access this page.
I am unable to switch between frames in Lookup window. There are two frames, one is search frame with textbox and button to search and below that is results frame for displaying search results with hyperlinks for selection. I am specifying the frames by frame name or id, but webDriver switches to search frame and does the searching but then is not able to locate the results frame with NoSuchFrameException.
If I do not switch to search frame initially but directly switch to results frame, it is indeed successful in the locating the results frame which displays results of some recent searches done by default.
How do I switch from search frame to results frame ? Given below is my code
public class Acc_Parent
{
WebDriver driver;
FileInputStream fis;
XSSFWorkbook wb;
XSSFSheet sh;
#Test
public void createParent() throws IOException, InterruptedException, FileNotFoundException
{
driver = new FirefoxDriver();
//System.setProperty("webdriver.chrome.driver", "D:/chromedriver_win32/chromedriver.exe");
//driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
driver.get("https://test.salesforce.com");
fis = new FileInputStream("C:/Users/psit/Documents/Login.xlsx");
wb = new XSSFWorkbook(fis);
sh = wb.getSheetAt(0);
driver.findElement(By.xpath(".//*[#id='username']")).sendKeys(sh.getRow(1).getCell(0).getStringCellValue());
driver.findElement(By.xpath(".//*[#id='password']")).sendKeys(sh.getRow(1).getCell(1).getStringCellValue());
driver.findElement(By.xpath(".//*[#id='Login']")).click();
fis = new FileInputStream("C:/Users/psit/Documents/Input.xlsx");
wb = new XSSFWorkbook(fis);
sh = wb.getSheet("Parent");
driver.findElement(By.xpath(".//*[#id='Account_Tab']/a")).click();
driver.findElement(By.xpath(".//*[#id='hotlist']/table/tbody/tr/td[2]/input")).click();
driver.findElement(By.xpath(".//*[#id='j_id0:acctFrm:nmsrch']")).sendKeys(sh.getRow(1).getCell(1).getStringCellValue());
driver.findElement(By.xpath(".//*[#id='j_id0:acctFrm']/div[1]/div[2]/table/tbody/tr/td[2]/input")).click();
try
{
driver.findElement(By.linkText("click here")).click();
driver.findElement(By.xpath(".//*[#id='parentAcc']")).sendKeys(sh.getRow(1).getCell(1).getStringCellValue());
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[#id='childAcc']")).sendKeys(sh.getRow(1).getCell(2).getStringCellValue());
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[#id='pg:acc:pb:acctAdd:rptAddFields:0:actFields']")).sendKeys(sh.getRow(1).getCell(3).getStringCellValue());
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[#id='pg:acc:pb:acctAdd:rptAddFields:2:actFields']")).sendKeys(sh.getRow(1).getCell(4).getStringCellValue());
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[#id='pg:acc:pb:acctAdd:rptAddFields:4:actFields']")).sendKeys(sh.getRow(1).getCell(5).getStringCellValue());
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[#id='pg:acc:pb:acctAdd:rptAddFields:6:actFields']")).sendKeys(sh.getRow(1).getCell(6).getStringCellValue());
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[#id='pg:acc:pb:acctAdd:rptAddFields:8:actFields']")).sendKeys(Integer.toString((int)sh.getRow(1).getCell(7).getNumericCellValue()));
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[#id='pg:acc:pb:acctAdd:rptAddFields:1:actFields']")).sendKeys(sh.getRow(1).getCell(8).getStringCellValue());
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[#id='pg:acc:pb:acctAdd:rptAddFields:3:actFields']")).sendKeys(sh.getRow(1).getCell(9).getStringCellValue());
String mainWindow = driver.getWindowHandle();
driver.findElement(By.xpath(".//*[#id='pg:acc:pb:acctAdd:rptAddFields:5:actFields_lkwgt']/img")).click();
Thread.sleep(5000);
Set<String> winhand = driver.getWindowHandles();
for(String str : winhand)
{
if(!str.equalsIgnoreCase(mainWindow))
{
driver.switchTo().window(str);
break;
}
}
try
{
driver.switchTo().frame("searchFrame");
driver.findElement(By.xpath(".//*[#id='lksrch']")).sendKeys(sh.getRow(1).getCell(10).getStringCellValue());
driver.findElement(By.xpath(".//*[#id='theForm']/div/div[2]/input[2]")).click();
Thread.sleep(5000);
driver.switchTo().frame("resultsFrame");
driver.findElement(By.linkText(sh.getRow(1).getCell(10).getStringCellValue())).click();
driver.switchTo().window(mainWindow);
driver.findElement(By.xpath(".//*[#id='pg:acc:pb:acctAdd:rptAddFields:7:actFields_lkwgt']/img")).click();
Thread.sleep(5000);
Set<String> winhandle = driver.getWindowHandles();
for(String str : winhandle)
{
if(!str.equalsIgnoreCase(mainWindow))
{
driver.switchTo().window(str);
break;
}
}
try
{
driver.switchTo().frame("searchFrame");
driver.findElement(By.xpath(".//*[#id='lksrch']")).sendKeys(sh.getRow(1).getCell(11).getStringCellValue());
driver.findElement(By.xpath(".//*[#id='theForm']/div/div[2]/input[2]")).click();
Thread.sleep(5000);
driver.switchTo().frame("resultsFrame");
driver.findElement(By.linkText(sh.getRow(1).getCell(11).getStringCellValue())).click();
driver.switchTo().window(mainWindow);
}
catch(Exception e)
{
e.printStackTrace();
System.out.println();
driver.close();
driver.switchTo().window(mainWindow);
System.out.println("State/Region not Found");
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println();
driver.close();
driver.switchTo().window(mainWindow);
}
driver.findElement(By.xpath(".//*[#id='pg:acc:pb:j_id34:save']")).click();
Before switching to resultsFrame try to switch to defaultContent or your main frame and then switch to resultsFrame. The thing is webdriver searches the frame in current context. So under searchFrame it will never find the resultsFrame (As both might be under main frame).
Hope this helps.
Related
Trying to locate Radio Button inside iFrame but getting error as No Such Element found.
Tried switching to iFrame but still getting the same error. Not sure what am I missing. Tried couple of methods but did not get through. Not sure if my Xpath is wrong or way I use id to locate element is wrong. [Verified my Xpath in Developer tools but still getting the same error of No suh Element found]
Thank you in advance.
public class Sap_Demo {
WebDriver driver;
JavascriptExecutor jse;
public static void main(String[] args)
{
Sap_Demo demoObj = new Sap_Demo();
demoObj.invokeBrowser();
demoObj.initializeSAPFiory();
demoObj.forecastMD61();
}
public void invokeBrowser()
{
System.setProperty("webdriver.chrome.driver", "U:\\Research Paper\\Selenium\\Drivers\\Chrome\\chromedriver_win32\\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().deleteAllCookies();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
}
public void initializeSAPFiory()
{
try
{
Thread.sleep(1200);
driver.get("https://dijon.cob.csuchico.edu:8042/erp");
driver.findElement(By.id("USERNAME_FIELD-inner")).sendKeys("H4");
Thread.sleep(1200);
driver.findElement(By.id("PASSWORD_FIELD-inner")).sendKeys("Onsjhjsa1087");
Thread.sleep(1200);
driver.findElement(By.id("CLIENT_FIELD-inner")).clear();
Thread.sleep(1200);
driver.findElement(By.id("CLIENT_FIELD-inner")).sendKeys("485");
Thread.sleep(1200);
driver.findElement(By.xpath("//span[#class='sapMBtnContent sapMLabelBold sapUiSraDisplayBeforeLogin']")).click();
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void forecastMD61()
{
try {
driver.findElement(By.id("erpsim-tcode-btn-img")).click();
Thread.sleep(1200);
driver.findElement(By.id("TCode-input-inner")).sendKeys("MD61");
Thread.sleep(1200);
driver.findElement(By.id("TCode-launchBtn-content")).click();
Thread.sleep(1200);
driver.switchTo().defaultContent();
WebElement iframe = driver.findElement(By.id("ITSFRAME1"));
driver.switchTo().frame(iframe);
/*driver.switchTo().frame(driver.findElement(By.xpath("//span[#id='M0:46:::4:2-imgSymb']")));
driver.findElement(By.xpath("//span[#id='M0:46:::4:2-imgSymb']")).sendKeys("ABC");*/
//driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
//Thread.sleep(1600);
/*driver.switchTo().frame("ITSFRAME1");
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("ITSFRAME1"));*/
/*WebElement E1 = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("M0:46:::4:2-imgStd")));
WebElement E1 = driver.findElement(By.xpath("//span[#id='M0:46:::4:2-imgSymb']"));
E1.click();*/
//driver.findElement(By.id("M0:46:::4:2-imgStd")).click();
//driver.findElement(By.xpath("//span[#id='M0:46:::4:2-imgStd']")).click();
//Thread.sleep(1200);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
Your first xpath for the element and the id for the iframe are correct, but as the window is getting opened in a new tab, you need to switch the driver to the new tab.
So, instead of using driver.switchTo().defaultContent();
You need to use:
ArrayList<String> tabs = new ArrayList<String> (driver.getWindowHandles());
driver.switchTo().window(tabs.get(1));
And if you want to switch to the original tab, you need to use:
driver.switchTo().window(tabs.get(0));
I have a tricky situation:
I am handling two popups after entering login info, but on the second pop-up I am not able to consistently hit the OK button every time
I have tried Waits, Storing Element in List and Switch cases
public class loginUser {
public static WebDriver driver = new InternetExplorerDriver();
public static void winHandles()
{
String newHandle = null;
Set<String> newHandles = driver.getWindowHandles();
Iterator<String> itr = newHandles.iterator();
while(itr.hasNext()){
newHandle = itr.next();
driver.switchTo().window(newHandle);
System.out.println(driver.getCurrentUrl());
}
}
public static void main(String args[]) throws InterruptedException
{
System.setProperty("","");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("");
driver.findElement(By.name("")).sendKeys("");
driver.findElement(By.name("")).sendKeys("");
driver.findElement(By.name("")).sendKeys("");
driver.findElement(By.id("")).click();
String parentWindowHandler = driver.getWindowHandle();
winHandles();
List<WebElement> yesbutton = driver.findElements(By.id("btnYes"));
for (int i = 0; i < 4; i++) {
if(yesbutton.get(0).isDisplayed())
{
yesbutton.get(0).click();
}
else {
System.out.println("button is creating problems");
}
}
driver.switchTo().window(parentWindowHandler);
System.out.println(driver.getCurrentUrl());
winHandles();
Thread.sleep(3000);
List<WebElement> okbutton = driver.findElements(By.id("btnOK"));
for (int i = 0; i < 4; i++) {
if(okbutton.get(0).isDisplayed())
{
okbutton.get(0).click();
}
else {
System.out.println("button is creating problems");
}
}
Thread.sleep(7000);
winHandles();
driver.findElement(By.name("")).click();
driver.findElement(By.id("")).click();
driver.findElement(By.name("")).click();
driver.findElement(By.id("")).click();
driver.findElement(By.name("")).click();
driver.close();
}}
So, this is the hard coded version
The locator with id btnOK is causing problems mostly.
Like 4 out of 5 times
I also have the same kind of issue while running test in firefox but in chrome, test runs successfully. You can use try catch :
try
{
okbutton.get(0).click();
}
catch(Exception e)
{
}
This is not advisable but due to browser compatibility, i had to use this as a temporary solution.If anyone has real solution kindly update me too...
I am facing issues with Selenium when navigating from one page to another.
Below is the code. If I click on following element a jQuery image will open until the next page gets loaded. But it's not navigating to next page itself. The image keeps on rotating and window will close that. Why?
I am getting a NoSuchElementFoundException
Chrome Version : 58.0.3029.110
driver.findElement(By.name("continue")).click();
#Test
public void executeLoginApp() throws InterruptedException {
driver.navigate()
.to("url with login application");
WebElement userName = driver.findElement(By.id("uname"));
WebElement pwd = driver.findElement(By.id("passwd"));
userName.sendKeys("test");
pwd.sendKeys("test");
Thread.sleep(2000);
javaScriptExecutor.executeScript("window.scrollTo(0, document.body.scrollHeight)");
Thread.sleep(2000);
//driver.findElement(By.xpath("//input[#name='continue']")).click();
//Thread.sleep(1000);
//driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
driver.findElement(By.name("continue")).click();
//signOn.click();
callYourInformation();
}
private void callYourInformation() {
/*try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
WebDriverWait wait = new WebDriverWait(driver, 10);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
String previousURL = driver.getCurrentUrl();
ExpectedCondition e = new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return (d.getCurrentUrl() != previousURL);
}};
wait.until(e);}*/
// currentURL = driver.getCurrentUrl();
if (driver.getCurrentUrl().contains("yourinfo")) {
// testing yourinfo page
WebElement emailAddress = driver.findElement(By.id("emailAddress"));
emailAddress.clear();
emailAddress.sendKeys("selenium#wwwmail.com");
WebElement addressLine1 = driver.findElement(By.id("addressLine1"));
addressLine1.clear();
addressLine1.sendKeys("New york");
WebElement grossAnnualIncome = driver.findElement(By.id("grossAnnualIncome"));
grossAnnualIncome.sendKeys(String.valueOf(6000));
WebElement submit = driver.findElement(By.id("submitApplication"));
submit.click();
driver.findElement(By.id("Continue")).click();
}
else{
do other logic.
}
I tried all the ways but no luck. Commented lines are my tries but none of them redirects to that page.
I'm trying to type selenium in google and get all the title text of result in a notepad file. i want to get all available links on all the pages, till last page of search. but only 1st page's link i am getting. when i debug and run, it is working for some 10 pages.help me in this.
JAVA code:
public class weblink
{
public static void main(String[] args) throws IOException, InterruptedException {
WebDriver driver;
System.setProperty("webdriver.chrome.driver", "E:\\disha.shah/myWork/eclipse/chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.google.co.in/");
driver.findElement(By.id("lst-ib")).sendKeys("Selenium");
driver.findElement(By.id("_fZl")).click();
PrintStream ps = new PrintStream(new File(("E:\\disha1.txt")));
do
{
List<WebElement> findElements = driver.findElements(By.xpath("//*[#id='rso']//h3/a"));
for (WebElement webElement : findElements)
{
System.out.println("-" + webElement.getText()); // for title
//System.out.println(webElement.getAttribute("href")); // for links
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
System.setOut(ps);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}
Thread.sleep(1000);
if(driver.findElement(By.linkText("Next")).isDisplayed()== true)
{
driver.findElement(By.linkText("Next")).click();
}
else
{
System.out.println("All Link is Covered");
}
}
while(driver.findElement(By.linkText("Next")).isDisplayed() );
{
//Thread.sleep(2000);
}
}
}
I've done some correction. the updated code is below.-
public static void main(String[] args) throws IOException, InterruptedException
{
WebDriver driver;
System.setProperty("webdriver.chrome.driver", "D:/Application/chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.get("http://www.google.co.in/");
driver.findElement(By.id("lst-ib")).sendKeys("Selenium");
driver.findElement(By.id("_fZl")).click();
Boolean nextButtonFlag = true;
// Create two separate file storing the result
PrintStream searchTitle = new PrintStream(new File(("D:\\Titles.txt")));
PrintStream searchLink = new PrintStream(new File(("D:\\Links.txt")));
do
{
List<WebElement> findElements = driver.findElements(By.xpath("//h3[#class='r']/a"));
for (WebElement element : findElements)
{
// Write all received links and title inn txt file
searchTitle.append(element.getText()+"\n");
searchLink.append(element.getAttribute("href")+"\n");
}
Thread.sleep(2000);
try
{
driver.findElement(By.linkText("Next")).click();
}
catch(Exception e)
{
// no more next button to navigate further link
nextButtonFlag=false;
}
Thread.sleep(2500);
}
while(nextButtonFlag);
System.out.println("Execution done");
searchTitle.close();
searchLink.close();
}
}
Currently working on Selenium WebDriver, Java and TestNG frame work.
Please give ideas about TestNG framework.
For example, i have a file test.java. I have written java code with
#BeforeTest , #Test, #AfterTest. while running the code each test is running and am getting how many test got passed and how many got failed.
But i want solution for the secnario:
I have two tabs called Default and Internal vs External
After clicking the default tab i want run many test for that particular tab, once those test executed then i need to click on the Internal vs External then i need to run all test belongs to that tab.
How can i get result in the TestNG frame work.
The following code:
public class OverviewAndEvolutionPR{
private static Logger Log = Logger.getLogger(OverviewAndEvolutionPR.class.getName());
private WebDriver driver;
private StringBuffer verificationErrors = new StringBuffer();
Properties p= new Properties();
public Selenium selenium;
//#BeforeMethod
#BeforeTest
public void Login() throws Exception {
driver = new FirefoxDriver();
try {
p.load(new FileInputStream("C:/Login.txt"));
} catch (Exception e) {
e.getMessage();
}
String url=p.getProperty("url");
DOMConfigurator.configure("src/log4j.xml");
Log.info("______________________________________________________________");
Log.info("Initializing Selenium...");
selenium = new DefaultSelenium("localhost", 4444, "*firefox",url);
Thread.sleep(5000);
Log.info("Selenium instance started");
try {
p.load(new FileInputStream("C:/Login.txt"));
} catch (Exception e) {
e.getMessage();
}
Log.info("Accessing Stored uid,pwd from the stored text file");
String uid=p.getProperty("loginUsername");
String pwd=p.getProperty("loginPassword");
Log.info("Retrieved uid pwd from the text file");
try
{
driver.get("https://test.com");//example i had given like this
}
catch(Exception e)
{
Reporter.log("network server is slow..check internet connection");
Log.info("Unable to open the website");
throw new Error("network server is slow..check internet connection");
}
performLogin(uid,pwd);
}
public void performLogin(String uid,String pwd) throws Exception
{
Log.info("Sign in to the OneReports website");
Thread.sleep(5000);
Log.info("Enter Username");
driver.findElement(By.id("loginUsername")).sendKeys(uid);
Log.info("Enter Password");
driver.findElement(By.id("loginPassword")).sendKeys(pwd);
//submit
Log.info("Submitting login details");
waitforElement(driver,120 , "//*[#id='submit']");
driver.findElement(By.id("submit")).submit();
Thread.sleep(6000);
Actions actions = new Actions(driver);
Log.info("Clicking on Reports link");
if(existsElement("reports")==true){
WebElement menuHoverLink = driver.findElement(By.id("reports"));
actions.moveToElement(menuHoverLink).perform();
Thread.sleep(6000);
}
else{
Log.info("element not present");
System.out.println("element not present -- so it entered the else loop");
}
Log.info("Clicking on Extranet link");
if(existsElement("extranet")==true){
WebElement menuHoverLink = driver.findElement(By.id("extranet"));
actions.moveToElement(menuHoverLink).perform();
Thread.sleep(6000);
}
else{
Log.info("element not present");
System.out.println("element not present -- so it entered the else loop");
}
Log.info("Clicking on PR link");
if(existsElement("ext-pr")==true){
WebElement menuHoverLink = driver.findElement(By.id("ext-pr"));
actions.moveToElement(menuHoverLink).perform();
Thread.sleep(6000);
}
else{
Log.info("element not present");
System.out.println("element not present -- so it entered the else loop");
}
Log.info("Clicking on Overview and Evolution PR link");
if(existsElement("ext-pr-backlog-evolution")==true){
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", driver.findElement(By.id("ext-pr-backlog-evolution") ));
Thread.sleep(6000);
}
else{
Log.info("element not present");
System.out.println("element not present -- so it entered the else loop");
}
}
//Filter selection-1
//This filter selection need to happen in Default tab
#Test()
public void Filterselection_1() throws Exception{
Log.info("Clicking on Visualization dropdown");
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("document.getElementById('visualizationId').style.display='block';");
Select select = new Select(driver.findElement(By.id("visualizationId")));
select.selectByVisibleText("Week");
Thread.sleep(6000);
Log.info("Clicking on Period dropdown");
JavascriptExecutor executor1 = (JavascriptExecutor)driver;
executor1.executeScript("document.getElementById('periodId').style.display='block';");
Select select1 = new Select(driver.findElement(By.id("periodId")));
select1.selectByVisibleText("Last 4 Weeks");
Thread.sleep(6000);
Log.info("Clicking on Type dropdown");
JavascriptExecutor executor2 = (JavascriptExecutor)driver;
executor2.executeScript("document.getElementById('classificationId').style.display='block';");
Select select2 = new Select(driver.findElement(By.id("classificationId")));
select2.selectByVisibleText("Customer PRs");
Thread.sleep(6000);
Log.info("Clicking on Apply Filter button");
driver.findElement(By.id("kpiFilterSubmit")).click();
}
//In the default tab many filter section i will have once it completed then i need to move to other tab and need to check the filter selection
//Filter selection-2
//It need to happen in the Internal vs External tab
#Test
public void Filterselection_2() throws Exception{
Log.info("Clicking Internal Vs External tab");
driver.findElement(By.linkText("Internal vs External")).click();
Thread.sleep(6000);
Log.info("Clicking on Visualization dropdown");
JavascriptExecutor executor3 = (JavascriptExecutor)driver;
executor3.executeScript("document.getElementById('visualizationId').style.display='block';");
Select select3 = new Select(driver.findElement(By.id("visualizationId")));
select3.selectByVisibleText("ICC");
Thread.sleep(6000);
Log.info("Clicking on Type dropdown");
JavascriptExecutor executor02 = (JavascriptExecutor)driver;
executor02.executeScript("document.getElementById('classificationId').style.display='block';");
Select select02 = new Select(driver.findElement(By.id("classificationId")));
select02.selectByVisibleText("Internal PRs");
Thread.sleep(6000);
Log.info("Clicking on topography dropdown");
JavascriptExecutor executor4= (JavascriptExecutor)driver;
executor4.executeScript("document.getElementById('topographyId').style.display='block';");
Select select4 = new Select(driver.findElement(By.id("topographyId")));
select4.selectByVisibleText("ICC");
Thread.sleep(6000);
Log.info("Clicking on Apply Filter button");
driver.findElement(By.id("kpiFilterSubmit")).click();
Thread.sleep(6000);
}
private boolean existsElement(String id) {
try {
driver.findElement(By.id(id));
} catch (Exception e) {
System.out.println("id is not present ");
return false;
}
return true;
}
private void waitforElement(WebDriver driver2, int i, String string) {
// TODO Auto-generated method stub
}
//#AfterMethod
#AfterTest
public void tearDown() throws Exception {
Log.info("Stopping Selenium...");
Log.info("______________________________________________________________");
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
Assert.fail(verificationErrorString);
}
}
}
Use the attribute dependsOnMethods, of #Test, to sequentialize your tests. You can read further about the annotations in TestNG at - TectNG Annotations.
So why don't you abstract those tests and than call it in your "Default" and "Internal vs External"? In you case I would use Page Objects
You can use Groups annotation in TestNG. Write all your required Test cases under Default tab, then add that test cases into one group as below
public class Test1 {
#Test(groups = { "functest", "checkintest" })
public void testMethod1() {
}
#Test(groups = {"functest", "checkintest"} )
public void testMethod2() {
}
#Test(groups = { "functest" })
public void testMethod3() {
}
}
And it will execute that particular group test cases, then it will execute another once group test cases are completed.
testng.xml
<test name="Test1">
<groups>
<run>
<include name="functest"/>
</run>
</groups>
<classes>
<class name="example1.Test1"/>
</classes>
</test>