Me Pehea te whakamahi i te Kaiwhakahaere Javascript WebDriver hei Whakatere ki te URL

Kei a Selenium WebDriver nga tikanga hei whakatere ki tetahi url; ko enei driver.get() me driver.navigate().to().

Hei tauira:

driver.get('https://devqa.io')

me

driver.navigate().to('https://devqa.io')

Kei kona ano tetahi atu huarahi ki te whakatere ki tetahi url ma te whakamahi i te Kaiwhakahaere Javascript a WebDriver, e whakaaturia ana i tenei tauira.



WebDriver - Whakatere ki URL Ma te JavaScript

Ma te whakamahi i window.location:

import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class WebDriverJSExecutor {
private static String url = 'https://devqa.io';
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
((JavascriptExecutor)driver).executeScript('window.location = ''+url+''');
} }