Uyisebenzisa kanjani iWebhu yeWebhu yeJavascript ukuze ujikeleze i-URL

I-Selenium WebDriver ibonelela ngeendlela zokuya kwi-url; ezi zi driver.get() kunye driver.navigate().to().

Umzekelo:

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


kwaye

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


Kukho enye indlela yokuhamba uye kwi-url kwaye usebenzisa i-WebDriver's Javascript Executor, njengoko kubonisiwe kulo mzekelo.



WebDriver -Khangela kwi-URL usebenzisa iJavaScript

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