Cara Nggunakake Pelaksana WebDriver Javascript kanggo Navigasi menyang URL

Selenium WebDriver nyedhiyakake cara kanggo navigasi menyang url; iki driver.get() lan driver.navigate().to().

Contone:

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


lan

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


Uga ana cara liya kanggo navigasi menyang url lan nggunakake WebDriver's Javascript Executor, kaya sing dituduhake ing conto iki.





WebDriver - Navigasi menyang URL Nggunakake JavaScript

Nggunakake 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+''');
} }