当我在selenium中运行以下类文件时,将启动浏览器并打开URL,但此后会出错:
global $wpdb;
$sql = $wpdb->prepare( "
SELECT DISTINCT
p.ID,
p.post_title,
lat.meta_value as locLat,
lng.meta_value as locLong,
( %d * acos(
cos( radians( %s ) )
* cos( radians( lat.meta_value ) )
* cos( radians( lng.meta_value ) - radians( %s ) )
+ sin( radians( %s ) )
* sin( radians( lat.meta_value ) )
) )
AS distance
FROM $wpdb->posts p
INNER JOIN $wpdb->postmeta lat ON p.ID = lat.post_id
INNER JOIN $wpdb->postmeta lng ON p.ID = lng.post_id
INNER JOIN $wpdb->postmeta venue_discontinued ON p.ID = venue_discontinued.post_id
WHERE 1 = 1
AND p.post_type = 'venue'
AND p.post_status = 'publish'
AND venue_discontinued.meta_value != 1
AND lat.meta_key = 'lat'
AND lng.meta_key = 'lng'
HAVING distance < %s
ORDER BY distance ASC",
$earth_radius,
$lat,
$lng,
$lat,
$distance
);
$wpdb->get_results( $sql );
代码试用:
exception in thread "main" java.lang.NullPointerException
at guru99project.guru99project.printtitlepage(guru99project.java:25)
at guru99project.Main_method.main(Main_method.java:10)
答案 0 :(得分:1)
您已经将驱动程序定义为 WebDriver 的全局实例(类级别),为:
public WebDriver driver;
因此,您无需在同一 Class 中的任何methods()
中定义 WebDriver 的任何其他新实例,并继续使用相同的 WebDriver 的全局定义实例,即 driver 。
您需要从以下行中删除 WebDriver :
WebDriver driver = new ChromeDriver();
所以行应该是:
driver = new ChromeDriver();
答案 1 :(得分:0)
您已经指定为public WebDriver driver;
因此您无需再次指定为,
Webdriver driver = new ChromeDriver();//if you need This , Then Don't Specify public Webdriver driver at the Top. Initialize here it self and Import it.
请将上述行更改为,
driver = new ChromeDriver();