getting below while running test case in selenium webdriver.
java.lang.RuntimeException: java.lang.NullPointerException
at ru.yandex.qatools.ashot.util.InnerScript.execute(InnerScript.java:29)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getFullHeight(ViewportPastingDecorator.java:67)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:41)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:35)
at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:143)
at selenium.org.sample.SampleProject.Screenshot.ScreenshotPage.ScreenshotPage1(ScreenshotPage.java:14)
below is my class to of screenshot
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import ru.yandex.qatools.ashot.AShot;
import ru.yandex.qatools.ashot.Screenshot;
import ru.yandex.qatools.ashot.shooting.ShootingStrategies;
import selenium.org.sample.SampleProject.TestBase.TestBase;
public class ScreenshotPage extends TestBase
{
public void ScreenshotPage1() throws InterruptedException, IOException
{
Screenshot fpScreenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);
ImageIO.write(fpScreenshot.getImage(),"PNG",new File("D:/selenium/"+System.currentTimeMillis()+".png"));
}
}
and below I am calling method of screenshotPage class.
import java.io.IOException;
import org.openqa.selenium.support.PageFactory;
import org.testng.Assert;
import org.testng.annotations.Test;
import selenium.org.sample.SampleProject.UIAction.SignIn;
import selenium.org.sample.SampleProject.ExcelReader.ExcelReader;
import selenium.org.sample.SampleProject.Screenshot.ScreenshotPage;
public class AppTest extends ExcelReader
{
@Test(dataProvider="testdata")
public void Log(String email,String pwd) throws IOException, InterruptedException
{
ScreenshotPage S=new ScreenshotPage();
System.out.println("Sign in page");
SignIn loginpage = PageFactory.initElements(driver, SignIn.class);
loginpage.setUserName(email);
loginpage.setPwd(pwd);
Thread.sleep(8000);
S.ScreenshotPage1();
loginpage.Sign_In_btn();
driver.manage().window().maximize();
try
{
Assert.assertEquals(driver.getTitle(),"My account - My Store");
System.out.println("Log IN successfull1");
}
catch(AssertionError E)
{
System.out.println("Log IN un-successfull"+E);
}
Thread.sleep(8000);
S.ScreenshotPage1();
}
What I have tried:
below code is running successfully facing this issue only when calling method.
import java.io.IOException;
import org.openqa.selenium.support.PageFactory;
import org.testng.Assert;
import org.testng.annotations.Test;
import selenium.org.sample.SampleProject.UIAction.SignIn;
import selenium.org.sample.SampleProject.ExcelReader.ExcelReader;
import selenium.org.sample.SampleProject.Screenshot.ScreenshotPage;
public class AppTest extends ExcelReader
{
@Test(dataProvider="testdata")
public void Log(String email,String pwd) throws IOException, InterruptedException
{
ScreenshotPage S=new ScreenshotPage();
System.out.println("Sign in page");
SignIn loginpage = PageFactory.initElements(driver, SignIn.class);
loginpage.setUserName(email);
loginpage.setPwd(pwd);
Thread.sleep(8000);
Screenshot fpScreenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);
ImageIO.write(fpScreenshot.getImage(),"PNG",new File("D:/selenium/"+System.currentTimeMillis()+".png"));
loginpage.Sign_In_btn();
driver.manage().window().maximize();
try
{
Assert.assertEquals(driver.getTitle(),"My account - My Store");
System.out.println("Log IN successfull1");
}
catch(AssertionError E)
{
System.out.println("Log IN un-successfull"+E);
}
Thread.sleep(8000);
S.ScreenshotPage1();
}