Issue :- java.lang.NoSuchMethodError: org.testng.remote.AbstractRemoteTestNG.addListener(Lorg/testng/ISuiteListener;)V
below Scripts to take a screen shot for a specific element from a page using selenium 4.5
package Demo.Selenium4updates;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import io.github.bonigarcia.wdm.WebDriverManager;
public class Selenium4features {
@Test
public static void test() throws IOException
{
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
driver.get("https://www.yet5.com/");
driver.manage().window().maximize();
WebElement element = driver.findElement(By.xpath("//div[@id='topyet5logo']"));
File f = element.getScreenshotAs(OutputType.FILE);
File logo = new File("logo.png");
FileUtils.copyFile(f, logo);
driver.quit();
}
}
Output :- As of now i am getting the error message as below.
[RemoteTestNG] detected TestNG version 7.0.1
java.lang.NoSuchMethodError: org.testng.remote.AbstractRemoteTestNG.addListener(Lorg/testng/ISuiteListener;)V
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
below Scripts to take a screen shot for a specific element from a page using selenium 4.5
package Demo.Selenium4updates;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import io.github.bonigarcia.wdm.WebDriverManager;
public class Selenium4features {
@Test
public static void test() throws IOException
{
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
driver.get("https://www.yet5.com/");
driver.manage().window().maximize();
WebElement element = driver.findElement(By.xpath("//div[@id='topyet5logo']"));
File f = element.getScreenshotAs(OutputType.FILE);
File logo = new File("logo.png");
FileUtils.copyFile(f, logo);
driver.quit();
}
}
Output :- As of now i am getting the error message as below.
[RemoteTestNG] detected TestNG version 7.0.1
java.lang.NoSuchMethodError: org.testng.remote.AbstractRemoteTestNG.addListener(Lorg/testng/ISuiteListener;)V
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Solution
1. Update the version for TestNG from 7.0.1 to some previous version like 6.10..
2. Note i have change the version coz my eclipse version is not update..
Suggestion
if you are using an older version of eclipse then use older version of testNG
for new version use current testNG releases.:
Please let me know if this helps..
Thanks
Post a Comment