Best Selenium code snippet using org.openqa.selenium.events.zeromq.ZeroMqEventBus.RejectedEvent
Selenium webdriver : List is not generic; it cannot be parameterized with arguments `<WebElement>` type
How to generate Java source code from Selenium IDE (IDE code is in HTML extension)
How to handle "Your connection is not secure" error in firefox using selenium
Selenium WebDriver - Unexpected modal dialog Alert
java.lang.UnsupportedClassVersionError: org/openqa/gr id/selenium/GridLauncher (Unsupported major.minor version 50.0)
How to check if an element is visible with WebDriver
Error Loading Extension Could not load extension from 'C:\..\Local\Temp\scoped_dir6312_32763\internal'. Loading of unpacked extensions is disabled
parameter is required by @ Test but has not been marked @optional or defined
Selenium web driver: cannot be scrolled into view
How to get WebElement text with Selenium
Here is the Answer to your Question:
The error says it all The type List is not generic; it cannot be parameterized with arguments <WebElement> type
. It means when you configured the List
as in List<WebElement> linkElements
, accidentally you have imported it from java.awt.List
where it is not defined. Hence the error.
The following screenshot shows it all:
As a solution, I have used your own code importing java.util.List
instead of java.awt.List
and your code block works just fine:
package demo;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Q45402867_tagname_a {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver","C:\\Utility\\BrowserDrivers\\geckodriver.exe");
WebDriver driver=new FirefoxDriver();
String baseUrl="https://www.udacity.com/";
driver.get(baseUrl);
String Title="Udacity - Free Online Courses and Nanodegree Programs";
List<WebElement> linkElements = driver.findElements(By.tagName("a"));
System.out.println(linkElements.size());
for (WebElement ele:linkElements)
System.out.println(ele);
}
}
The output on the console is:
86
[[FirefoxDriver: firefox on ANY (ef81931f-9530-4998-8405-6581ab51c86e)] -> tag name: a]
... 84 more ...
[[FirefoxDriver: firefox on ANY (ef81931f-9530-4998-8405-6581ab51c86e)] -> tag name: a]
Let me know if this Answers your Question.
Check out the latest blogs from LambdaTest on this topic:
This article is a part of our Content Hub. For more in-depth resources, check out our content hub on A Detailed TestNG Tutorial.
This article is a part of our Content Hub. For more in-depth resources, check out our content hub on JUnit Tutorial.
This article is a part of our Content Hub. For more in-depth resources, check out our content hub on Selenium Cucumber Tutorial.
There are a lot of tools in the market who uses Selenium as a base and create a wrapper on top of it for more customization, better readability of code and less maintenance for eg., Watir, Protractor etc., To know more details about Watir please refer Cross Browser Automation Testing using Watir and Protractor please refer Automated Cross Browser Testing with Protractor & Selenium.
Are you looking for the top books for Automation Testers? Ah! That’s why you are here. When I hear the term book, This famous saying always spins up in my head.
LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.
Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.
What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.
Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.
Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.
How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.
Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.
Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.
LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.