Issue with scenario of login in data driven framework | Selenium Forum
M
Posted on 27/04/2016
Sir,

Am trying to automate login scenario for rediffcom
http://in.rediff.com/ ---->click on moneyID---->Sign

Have scripted for it & it works fine.
[b:1xfaahsn]Issue: when i organize the code into library functions in data driven framework... the same code does not work.[/b:1xfaahsn]
[b:1xfaahsn]I get "No such Element Found" on testexecution.[/b:1xfaahsn]

Am attaching the project & Test am running is in SuiteB>TestCase_B4_chai

Also find java file which works fine on execution.

M
Replied on 28/04/2016

send a screen shot.


M
Replied on 28/04/2016

Attaching screenshot

Responsive image

M
Replied on 28/04/2016

problem is not with the framework but with xpath. try wait statement.


M
Replied on 28/04/2016

Sir,
[b:8w9a5rpb]Sir ,This works fine ....[/b:8w9a5rpb]

package p1;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class Logins {
public static WebDriver w=new FirefoxDriver();
public static void main(String[] args) {
// TODO Auto-generated method stub

WebDriver w=new FirefoxDriver();
w.get("http://in.rediff.com/");
//w.findElement(By.xpath("//*[@id='homewrapper']/div[5]/a[3]/div/u")).click();//THIS ALSO WORKS FINE
w.findElement(By.xpath("//u[text()='Money']")).click();


WebDriverWait ww=new WebDriverWait(w,30);
ww.until(ExpectedConditions.elementToBeClickable(By.linkText("Sign In"))).click();


ww.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='useremail']"))).sendKeys("chaitra.jagirdar7@gmail.com");
ww.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='emailsubmit']"))).click();

ww.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='userpass']"))).sendKeys("Chaitra@1987");
ww.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='loginsubmit']"))).click();
//System.out.println("*****"+isElementPresent("//*[@id='signin_info']/a"));

}

}


[b:8w9a5rpb]But below code does not ....

Here are my respective calls & respective library methods ....
Have also used wait ...as a call [/b:8w9a5rpb]

/*******************webDriver calls*********************************/

openBrowser(browser);
Navigate("Url_Navigate_To");
HandleWindowpops();
Wait_implicit(50);
APP_LOGS.warn("Title of current window"+w.getTitle());
click("Money_Id");
//----------------------------------------------------------------------------------------------------------------------------
Library methods :

Attaching respective file


M
Replied on 28/04/2016

Sir ,

i tried APP_LOGS.warn(isElementPresent("Money_Id3"));//where money_IDs i supplied are as follows :

Money_Id1=//*[@id='homewrapper']/div[5]/a[3]/div/u
Money_Id2=//div[@class='icondiv']/a[3]/div/u
Money_Id3=html/body/div[2]/div[5]/a[3]/div/u
Money_Id=//u[text()='Money']

All the time isElementPresent(so nso) returns false....

Even absolute path for the object is of no use
Have priorly used a wait of 50 implicit.
[b:tg8pignm]
Query:What could have been wrong sir ??[/b:tg8pignm]


M
Replied on 29/04/2016

[quote:j4q19a6c]Money_Id=//u[text()='Money']
[/quote:j4q19a6c]

this xpath doesn't exists.

Responsive image

M
Replied on 29/04/2016

ya sir ,you were right...

[b:2pxkkm7d]Now, am unable to click continue button..But i checked it using iselementpresent, n method returns true but unable to click it:[/b:2pxkkm7d]

Have used following :lines of code & generic methods:

openBrowser(browser);
Navigate("Url_Navigate_To");
HandleWindowpops();
Wait_implicit(500);
APP_LOGS.warn("Title of current window"+w.getTitle());
APP_LOGS.warn(isElementPresent("Money_xpath"));
Assert.assertTrue(isElementPresent("Money_xpath"), "Money object in page was not found");
click("Money_xpath");
APP_LOGS.warn("SigIn_xpath:"+isElementPresent("SigIn_xpath"));
Assert.assertTrue(isElementPresent("SigIn_xpath"), "SignIN object in page was not found");
click("SigIn_xpath");
APP_LOGS.warn("EmailField_Id:"+isElementPresent("EmailField_xpath"));
Assert.assertTrue(isElementPresent("EmailField_xpath"), "EmailID object in page was not found");
input("EmailField_xpath",username);
APP_LOGS.warn("emailsubmit_xpath:"+isElementPresent("emailsubmit_xpath"));
Assert.assertTrue(isElementPresent("emailsubmit_xpath"), "emailsubmit_xpath object in page was not found");
WaitForElement("emailsubmit_xpath",30);
//w.findElement(By.xpath("//*[@id='emailsubmit']")).click();
[b:2pxkkm7d]click("emailsubmit_xpath");//===================================>This line is not workng as expected[/b:2pxkkm7d]
====================================================================================================

public void click(String identifier) {
// TODO Auto-generated method stub
if(identifier.endsWith("_xpath"))//emailsubmit_xpath
w.findElement(By.xpath(CONFIG.getProperty(identifier))).click();
else if(identifier.endsWith("_Id"))
w.findElement(By.id(CONFIG.getProperty(identifier))).click();
else if(identifier.endsWith("_LinkText"))
w.findElement(By.linkText(CONFIG.getProperty(identifier))).click();
else if(identifier.endsWith("_Class"))
w.findElement(By.className(CONFIG.getProperty(identifier))).click();
}
[b:2pxkkm7d]
Attaching project >SuiteB>TestCase_B4_chai[/b:2pxkkm7d]


M
Replied on 30/04/2016

Issue is resolved sir...

[b:3cauratt]Query here:In login scenario, i call Evaluate method to compare results:Now how do i supply respective Test's XLS instance to GetColumnData?[/b:3cauratt]

As in see :[b:3cauratt]suiteBxls[/b:3cauratt]

i have public String GetColumnData(String sheetName,String ColName)
{
colData=[b:3cauratt]suiteBxls[/b:3cauratt].getCellData(sheetName, ColName, RowNum);//[b:3cauratt]See this line of code..[/b:3cauratt]

RowNum++;
APP_LOGS.warn("colData"+colData);
return colData;



}

===========================================================================================
public void Evaluate(Boolean ResultTestExecution)
{

if(GetColumnData(this.getClass().getSimpleName(),"Expected Result").equals("Success"))
{
x=true;
System.out.println("1st");
}
else
if(GetColumnData(this.getClass().getSimpleName(),"Expected Result").equals("Failure"))
{
x=false;
System.out.println("2nd");
}
else
if(GetColumnData(this.getClass().getSimpleName(),"Expected Result").equals("NA"))
{System.out.println("3rd");
RowNum++;
if(GetColumnData(this.getClass().getSimpleName(),"Expected Result").equals("Failure"))
{
x=false;
}
else
{
x=true;
}}

System.out.println("x"+x+"ResultTestExecution"+ResultTestExecution+"*****************************************");
if( !(x && ResultTestExecution))

Assert.fail("LOGIN FAILED DUE TO unknown reasons-3rdcase");
}