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(“http://only-testing-blog.blogspot.in/2013/11/new-test.html”); 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(“browser.download.folderList”, 2); profile.setPreference(“browser.download.dir”, path); profile.setPreference(“browser.download.alertOnEXEOpen”, false); profile.setPreference(“browser.helperApps.neverAsksaveToDisk”, “application/x-msexcel,application/excel,application/x-excel,application/excel,application/x-excel,application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel”); profile.setPreference(“browser.download.manager.showWhenStarting”, false); profile.setPreference(“browser.download.manager.focusWhenStarting”, false); profile.setPreference(“browser.helperApps.alwaysAsk.force”, false); profile.setPreference(“browser.download.manager.alertOnEXEOpen”, false); profile.setPreference(“browser.download.manager.closeWhenDone”, false); profile.setPreference(“browser.download.manager.showAlertOnComplete”, false); profile.setPreference(“browser.download.manager.useWindow”, false); profile.setPreference(“browser.download.manager.showWhenStarting”, false); profile.setPreference(“services.sync.prefs.sync.browser.download.manager.showWhenStarting”, false); profile.setPreference(“pdfjs.disabled”, true); WebDriver driver = new FirefoxDriver(profile); For complete MIME types list follow the link: http://qaautomationworld.blogspot.in/2014/02/file-downlaoding-using-selenium.html

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 = “the-site.com”; 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); selectMonth.click(); WebElement option = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(“//div[text() = ‘May’]”))); builder.mouse.mouseMove(((Locatable)option).coordinates); option.click(); System.out.println(“may slected…”); Edited: if you want to … Read more