What is the difference between cssSelector & Xpath and which is better with respect to performance for cross browser testing?

CSS selectors perform far better than Xpath and it is well documented in Selenium community. Here are some reasons, Xpath engines are different in each browser, hence make them inconsistent IE does not have a native xpath engine, therefore selenium injects its own xpath engine for compatibility of its API. Hence we lose the advantage … Read more

Using implicit wait in selenium

ImplicitWait ImplicitWait as per the Java Docs is to specify the amount of time the WebDriver instance i.e. the driver should wait when searching for an element if it is not immediately present in the HTML DOM in-terms of NANOSECONDS, MICROSECONDS, MILLISECONDS, SECONDS, MINUTES, HOURS or DAYS when trying to find an element or elements … Read more

Scroll Element into View with Selenium

Have tried many things with respect to scroll, but the below code has provided better results. This will scroll until the element is in view: WebElement element = driver.findElement(By.id(“id_of_element”)); ((JavascriptExecutor) driver).executeScript(“arguments[0].scrollIntoView(true);”, element); Thread.sleep(500); //do anything you want with the element

How to click on SVG elements using XPath and Selenium WebDriver through Java

Try following XPath and let me know if problem still persist: //div[@id=”avg_score_chart”]//*[name()=”svg”] For <g> elements: //div[@id=”avg_score_chart”]//*[name()=”svg”]/*[name()=”g”] Update Finally, this should be nearly the best option: //div[@class=”portlet light boxshadow”][contains(.,”Store Wise Performance”)]/div//div[@class=”amcharts-chart-div”]/*[name()=”svg”]//*[name()=”g”]/*[name()=”path” and @fill=”rgb(242,244,28)”]

Can Selenium interact with an existing browser session?

This is a duplicate answer **Reconnect to a driver in python selenium ** This is applicable on all drivers and for java api. open a driver driver = webdriver.Firefox() #python extract to session_id and _url from driver object. url = driver.command_executor._url #”http://127.0.0.1:60622/hub” session_id = driver.session_id #’4e167f26-dc1d-4f51-a207-f761eaf73c31′ Use these two parameter to connect to your driver. … Read more

Which Firefox browser versions supported for given Geckodriver version?

This Question have been surfacing out quite often for sometime now since we migrated from the legacy Firefox releases to Marionette based Mozilla Firefox releases (beginning with Firefox 48). It is not clear what exactly you mean by the code was working with geckodriver-v0.16.1 for older firefox versions. In general, each GeckoDriver release supports each … Read more

How does chrome driver interact with Chrome browser?

At the core of Selenium is WebDriver, which is the remote control interface that enables introspection and control of user agents. WebDriver provides a platform and language-neutral wire protocol as a way for out-of-process programs to remotely instruct the behavior of web browsers, hence instruction sets that can be run interchangeably in many browsers. Selenium … Read more

NoSuchElementException, Selenium unable to locate element

NoSuchElementException org.openqa.selenium.NoSuchElementException popularly known as NoSuchElementException extends org.openqa.selenium.NotFoundException which is a type of WebDriverException. NoSuchElementException can be thrown in 2 cases as follows : When using WebDriver.findElement(By by) : //example : WebElement my_element = driver.findElement(By.xpath(“//my_xpath”)); When using WebElement.findElement(By by) : //example : WebElement my_element = element.findElement(By.xpath(“//my_xpath”)); As per the JavaDocs just like any other WebDriverException, … Read more