When using this class in Selenium WebDriver:
package Selenium3;
import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class Jobs {
static WebDriver driver;
public Jobs(WebDriver driver) {
this.driver = driver;
}
public static void con() throws InterruptedException {
List<WebElement> element = driver.findElements(By.cssSelector(".position_title.ng-binding"));
for (int i = 0; i < element.size(); i++) {
Thread.sleep(2000);
String u = element.get(i).getText();
if (u.contains("Java"));
System.out.println(u);
}
}
}
The driver is always null. In the end I want to call this method from my Main class. What am I doing wrong?