Selenium how to manage wait for page load?

To wait for document.readyState to be complete isn’t a full proof approach to ensure presence, visibility or interactibility of an element. Hence, the function: JavascriptExecutor js = (JavascriptExecutor) driver.getWebDriver(); String result = js.executeScript(“return document.readyState”).toString(); if (!result.equals(“complete”)) { Thread.sleep(1000) } } And even waiting for jQuery.active == 0: public void WaitForAjax2Complete() throws InterruptedException { while (true) … Read more

Getting Timed out receiving message from renderer: 600.000 When we execute selenium scripts using Jenkins windows service mode

Seems you are using the following configuration: chromedriver=73.0.3683.68 chrome=73.0.3683.68 Windows OS John Chen (Owner – chromedriver) recently have confirmed that, We have confirmed issues with take screenshot when Chrome 73.0.3686.75 is started by a service (such as Jenkins or Task scheduler) on Windows. Please see https://crbug.com/942023 for more details. We apologize for any inconvenience caused … Read more

org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities while initiating Firefox v37 through Selenium v3.11.0

To keep things simple, as you are using Selenium Client v3.11.0 and Firefox v37 you need to download the latest GeckoDriver from mozilla/geckodriver and save it any where within your system. Next within the System.setProperty() line pass the Key webdriver.gecko.driver along with the Value as the absolute path of the GeckoDriver and finally through DesiredCapabilities … Read more

Find an element by text and get xpath – selenium webdriver junit

You can also use this to crawl up and generate the xpath: Call the method below with generateXPATH(element, “”); The output will be something like: /html[1]/body[1]/div[5]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/form[1]/div[2]/div[1]/input[2] METHOD private String generateXPATH(WebElement childElement, String current) { String childTag = childElement.getTagName(); if(childTag.equals(“html”)) { return “/html[1]”+current; } WebElement parentElement = childElement.findElement(By.xpath(“..”)); List<WebElement> childrenElements = parentElement.findElements(By.xpath(“*”)); int count = 0; … Read more

Which is the best and fastest way to find the element using webdriver? By.XPath or By.ID or anything else? And why? [closed]

Finding elements by ID is usually going to be the fastest option, because at its root, it eventually calls down to document.getElementById(), which is optimized by many browsers. Finding elements by XPath is useful for finding elements using very complex selectors, and is the most flexible selection strategy, but it has the potential to be … Read more

Is it Firefox or Geckodriver, which creates “rust_mozprofile” directory

If you have a closer look at the geckodriver v0.18.0 logs closely you will observe the very first occurrence of rust_mozprofile occurs in the following line: 1504762617094 Marionette CONFIG Matched capabilities: {“browserName”:”firefox”,”browserVersion”:”56.0″,”platformName”:”windows_nt”,”platformVersion”:”6.2″,”pageLoadStrategy”:”normal”,”acceptInsecureCerts”:false,”timeouts”:{“implicit”:0,”pageLoad”:300000,”script”:30000},”rotatable”:false,”specificationLevel”:0,”moz:processID”:5848,”moz:profile”:”C:\\Users\\AtechM_03\\AppData\\Local\\Temp\\rust_mozprofile.OfFuR9ogm33d”,”moz:accessibilityChecks”:false,”moz:headless”:false} This log clearly indicates that marionette is being configured with: “moz:profile”:”C:\\Users\\AtechM_03\\AppData\\Local\\Temp\\rust_mozprofile.OfFuR9ogm33d” And this configuration is done by the WebDriver instance i.e. the GeckoDriver. … Read more

Selenium Webdriver – click on hidden elements

Try this: WebElement elem = yourWebDriverInstance.findElement(By.xpath(“//*[@class=”goog-menu goog-menu-vertical uploadmenu density-tiny”]/input”)); String js = “arguments[0].style.height=”auto”; arguments[0].style.visibility=’visible’;”; ((JavascriptExecutor) yourWebDriverInstance).executeScript(js, elem); The above bunch would change the visibility of your file input control. You can then proceed with the usual steps for file upload like: elem.sendKeys(“<LOCAL FILE PATH>”); Be aware, by changing the visibility of an input field you … Read more

Which Firefox version is compatible with Selenium 3.6.0

Selenium with Gecko Driver Selenium Release Perspective : Selenium v3.6.0 (Java) Release explicitly didn’t mention any dependency explicitly. The last dependency explicitly mentioned by Selenium was for v3.4.0 which is as follows : Geckodriver 0.16 is strongly recommended GeckoDriver Release Perspective : GeckoDriver v0.19.0: Firefox 55.0 (and greater) & Selenium 3.5 (and greater) GeckoDriver v0.18.0: … Read more

I need to find an element in Selenium by CSS

Only using class names is not sufficient in your case. By.cssSelector(“.ban”) has 15 matching nodes By.cssSelector(“.hot”) has 11 matching nodes By.cssSelector(“.ban.hot”) has 5 matching nodes Therefore you need more restrictions to narrow it down. Option 1 and 2 below are available for CSS selector, 1 might be the one that suits your needs best. Option … Read more

What is the difference between a CSS and XPath selector? And which is better with respect to performance for cross-browser testing?

CSS selectors perform far better than XPath selectors, and it is well documented in Selenium community. Here are some reasons: XPath engines are different in each browser, hence making them inconsistent Internet Explorer does not have a native XPath engine, and therefore Selenium injects its own XPath engine for compatibility of its API. Hence we … Read more