JavaScript Executor in Selenium WebDriver

It works for me; you had a mistake on JavaScriptExecutor with upper case S. Instead, you should have javascriptExecutor with lower case s. Try this code: import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; public class GetDomain_JS { public static void main(String[] args) { WebDriver driver=new FirefoxDriver(); driver.get(“”); driver.manage().window().maximize(); System.out.println(driver.getCurrentUrl()); JavascriptExecutor js=(JavascriptExecutor) driver; String domain_name=(String) js.executeScript(“return document.domain”); … Read more

How to handle file download popup using Selenium WebDriver?

Try below code FirefoxProfile profile = new FirefoxProfile(); String path = “D:\\Downloads_sel”; profile.setPreference(“”, 2); profile.setPreference(“”, path); profile.setPreference(“”, false); profile.setPreference(“browser.helperApps.neverAsksaveToDisk”, “application/x-msexcel,application/excel,application/x-excel,application/excel,application/x-excel,application/excel,application/,application/x-excel,application/x-msexcel”); profile.setPreference(“”, false); profile.setPreference(“”, false); profile.setPreference(“browser.helperApps.alwaysAsk.force”, false); profile.setPreference(“”, false); profile.setPreference(“”, false); profile.setPreference(“”, false); profile.setPreference(“”, false); profile.setPreference(“”, false); profile.setPreference(“”, false); profile.setPreference(“pdfjs.disabled”, true); WebDriver driver = new FirefoxDriver(profile); For complete MIME types list follow the link:

What is the use of DesiredCapabilities in Selenium WebDriver?

You should read the documentation about DesiredCapabilities. There is also a different page for the ChromeDriver. Javadoc from Capabilities: Capabilities: Describes a series of key/value pairs that encapsulate aspects of a browser. Basically, the DesiredCapabilities help to set properties for the WebDriver. A typical usecase would be to set the path for the FirefoxDriver if … Read more

Chrome not reachable Selenium WebDriver error

Your chromedriver is starting just fine: “Starting ChromeDriver 2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 43967” The problem is the browser itself is not responding. So I have two ideas: 1) Your browser is not installed in the default location; If this is the case, add this to your code: ChromeOptions options = new ChromeOptions(); options.setBinary(“/path/to/other/chrome/binary”); DesiredCapabilities capabilities … Read more

Unable to locate SVG elements through xpath on Kendo UI chart

Hi you can click India with the following Xpath //*[text()=’India’] This is a really helpful resource I usually open chrome inspector and then hit cntrl+F to open up an interactive way to test my xpaths: You can target the svgs by using their strokes, but note these may change often. example: //*[@d=’M54.5 164.5 L 70.5 … Read more

How to handle login pop up window using Selenium WebDriver?

Use the approach where you send username and password in URL Request: http://username:[email protected] So just to make it more clear. The username is username password is password and the rest is usual URL of your test web Works for me without needing any tweaks. Sample Java code: public static final String TEST_ENVIRONMENT = “”; private … Read more

How to create Gmail account using Selenium, I am having trouble with month and country drop downs

As I see at here the month drop down box is not actually a select element, you should try using Actions as below: WebDriverWait wait = new WebDriverWait(d, 10); Actions builder = new Actions(d); WebElement selectMonth = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(“//div[@title=”Birthday”]”))); builder.mouse.mouseMove(((Locatable)selectMonth).coordinates);; WebElement option = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(“//div[text() = ‘May’]”))); builder.mouse.mouseMove(((Locatable)option).coordinates);; System.out.println(“may slected…”); Edited: if you want to … Read more