watch POM with page factory framework.
you have to create initElement() function to create the object for user name and password.
Sir ,
I am facing same problem again , I am automating Linkedin Login.
I am not at all understanding why is it throwing null pointer exception . In following code if i Uncomment the code [which is highlighted in green] then it works fine.
I have improvised code and imported the methods [b:31ltwhvh]initConfiguration(); initDriver();[/b:31ltwhvh] . Kindly find my code in the attachment.
package rough_testing_package;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.PageFactory;
import com.facebook.pages.LandingPage;
import com.facebook.pages.LoginPage;
import rough_testing_package.TestBase;
public class TestRough extends TestBase {
public static WebDriver driver;
public TestRough(WebDriver dr) {
driver = dr;
}
public static void main(String[] args) throws InterruptedException {
[b:31ltwhvh]initConfiguration();
initDriver();[/b:31ltwhvh]
/* [color=#004000:31ltwhvh] System.setProperty("webdriver.chrome.driver",
System.getProperty("user.dir") + "\\chrome\\chromedriver.exe");
driver = new ChromeDriver(); driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS)
.pageLoadTimeout(30, TimeUnit.SECONDS);
driver.navigate().to("https://in.linkedin.com/");[/color:31ltwhvh]
*/
LoginPage lp = PageFactory.initElements(driver, LoginPage.class);
LandingPage landing = lp.doLogin("",
"");
landing.verifyLinkedinLogo();
}
}
I have mailed my project on
[b:27sg5hq0]its.thakur@gmail.com[/b:27sg5hq0] and[b:27sg5hq0] info@qtpselenium.com [/b:27sg5hq0]
Because i am unable to attach my project in the attachment on the Board.
Kindly use following classes,
[b:27sg5hq0]TestClass.Java[rough_testing_package],
LoginPage.java[com.facebook.pages],
LandingPage.java[com.facebook.pages],
TopMenu.java[com.facebook.pages],
Constants.java[com.facebook.util].[/b:27sg5hq0]
I have automated Linkedin Webpages.
we didn't get the full project only 3 txt files. please provide us your full project so we can assist you.
Sir,
I have already mailed the project on
[b:2g02e1gb]its.thakur@gmail.com and info@qtpselenium.com [/b:2g02e1gb]
My mail id is atulpatil33347@hotmail.com.
i rechecked my mail just now. I have sent project on the mail.
found the problem
[quote:3gbdq0g0]
initDriver();[/quote:3gbdq0g0]
this method is not initializing the driver from logintest.java but it making a new webdriver object in testbase.java and initialing driver in it.
so how can i solve this issue ?
and use the driver which is initialized in TestBase.java
initiate driver in Testbase.java class constructor and then extend that class all the tests. and use the extended driver.