Good Morning,
I need to launch the chrome driver using selenium, then use it to call Web UI methods in the test cases. the driver launched and opened successfully, but then Web UI methods such as (click, send keys…) in the test cases marked as passed while actually they didn’t, therefore the next step can’t be executed.
it’s noteworthy that the same method sometimes works and sometimes doesn’t.
My Code
def public downloadDocumentSetup() {
String OldDownloadsPath=RunConfiguration. getProjectDir () + "/Downloads"
String DownloadsPath= OldDownloadsPath.replace("/", "\\")
HashMap<Object, String> chromePrefs = new HashMap<Object, String>();
chromePrefs.put("download.default_directory", DownloadsPath)
chromePrefs.put("profile.default_content_settings.popups",0)
chromePrefs.put("download.prompt_for_download", false)
chromePrefs.put("safebrowsing.enabled", "true");
ChromeOptions options = new ChromeOptions()
options.setExperimentalOption("prefs", chromePrefs)
DesiredCapabilities cap = DesiredCapabilities.chrome()
cap.setCapability(ChromeOptions.CAPABILITY, options)
System.setProperty("webdriver.chrome.driver", DriverFactory.getChromeDriverPath())
WebDriver driver = new ChromeDriver(cap)
DriverFactory.changeWebDriver(driver)
RunConfiguration. setWebDriverPreferencesProperty ("prefs", chromePrefs)
}
My Test Case
WebUI.navigateToUrl(GlobalVariable.WWWSite)
WebUI.click(findTestObject(‘Pages/MyFirstObject’))
WebUI.click(findTestObject(‘Pages/MySecondObject’))
Result
The browser opened and navigated to the website successfully, and the first click step marked as passed but actually it didn’t pass, therefore the next click action is not working.
Note
My Test case works perfectly when I use ‘Open Browser’ method to launch the driver.