0

I am new to selenium.

In below code firefox is being launched but i am unable to make any entry in the textbox.

package webdrivers;

import java.sql.Driver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.server.handler.SendKeys;

public class Automation 
{
    public static void main(String[] args) 
    {
       WebDriver driver = new FirefoxDriver();
       driver.get("https://www.facebook.com/");
       driver.findElement(By.name("email")).sendKeys("your_username");   
    }
}

Error is:-

Exception in thread "main" org.openqa.selenium.InvalidArgumentException: Expected [object Undefined] undefined to be a string Build info: version: 'unknown', revision: '5234b32', time: '2017-03-10 09:00:17 -0800' System info: host: 'RAHUL', ip: '192.168.1.109', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_121' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{moz:profile=C:\Users\lenovo\AppData\Local\Temp\rust_mozprofile.cduJLZVQoFth, rotatable=false, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=53.0, platformVersion=6.3, moz:processID=6184, browserName=firefox, platformName=windows_nt}] Session ID: 452dde13-0981-4d4d-bb9a-beb6739485d5
4
  • You probably need By.id("email"), I guess the WebElement returned by driver.findElement(By.name("email")) is undefined Commented Apr 27, 2017 at 10:50
  • It's not working with id also. Throwing the same error. Commented Apr 27, 2017 at 10:55
  • I think both ways should work, I guess Dev's answer (Gecko driver) will fix your problem. Commented Apr 27, 2017 at 10:57
  • @bert I agree, both should work but I always try to provide the minimal tweak needed in OP's code to make his/her code work :) Commented Apr 27, 2017 at 10:59

3 Answers 3

2

To work with Selenium 3.4.0 you need to download gecko driver v0.16.0 or higher from here and save it. Upgrade your Mozila Firefox to 53.x

Next you need to provide the absolute path of the gecko driver in your code. Your code will look like:

    System.setProperty("webdriver.gecko.driver",  "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
    FirefoxDriver driver =  new FirefoxDriver();
    driver.manage().window().maximize();
    driver.get("https://www.facebook.com/");
    driver.findElement(By.name("email")).sendKeys("your_username");

Let me know if this helps you.

Sign up to request clarification or add additional context in comments.

2 Comments

1493291531075 addons.manager ERROR startup failed: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIFile.create]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: resource://gre/modules/FileUtils.jsm :: FileUtils_getDir :: line 70" data: no] StackJ traavcaeS:c rFiiplte Uetrirlosr_:g erteDsioru(r)c@er:e/s/ogurrec/em:o/d/greu/modluelse/sA/dFdiolneMUatnialgse.rj.sjms:m7,0 l<i Fniel e1U6t5i7l:s NgSe_tEFRiRlOeR()N@OrTe_sIoNuIrTcIeA:L/I/ZgErDe:/ mAddoondMualneasg/eFri liesU tniolts i.njistmi:a4l2i z<e dv a Now a different error.
Thats because you have several addons in your Mozilla Firefox profile. You have 2 options, The easier one is to delete the add-ons and retest. Else you have to create a new Firefox profile.
1

Try this way..Download gecko_driver from this link

Note:- If your dealing with latest gecko driver version(v0.16.0), make sure your firefox browser is updated to latest version(V53).

Update selenium jar files as well as. you can download selenium latest jar files from this link

System.setProperty("webdriver.gecko.driver", "C:\\Drivers\\geckodriver.exe");   // Your gecko_driver path.
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.get("https://www.facebook.com");
driver.findElement(By.name("email")).sendKeys("Username");

5 Comments

1493291531075 addons.manager ERROR startup failed: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIFile.create]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: resource://gre/modules/FileUtils.jsm :: FileUtils_getDir :: line 70" data: no] StackJ traavcaeS:c rFiiplte Uetrirlosr_:g erteDsioru(r)c@er:e/s/ogurrec/em:o/d/greu/modluelse/sA/dFdiolneMUatnialgse.rj.sjms:m7,0 l<i Fniel e1U6t5i7l:s NgSe_tEFRiRlOeR()N@OrTe_sIoNuIrTcIeA:L/I/ZgErDe:/ mAddoondMualneasg/eFri liesU tniolts i.njistmi:a4l2i z<e dv a A different error.
Have you replace a gecko_driver path properly?
package webdrivers; public class Automation { public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\\Program Files\\gecko driver\\geckodriver-v0.16.1-win64\\geckodriver.exe"); WebDriver driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.get("facebook.com/"); driver.findElement(By.id("email")).sendKeys("your_username"); } } Yaa i did but not working..!!
driver.findElement(By.xpath("//input[@type='email']")).sendKeys("Username");
Update above line of code from your script and then check. your firefox browser version? have you installed latest selenium jar files (3.4.0)?
1

This is an ongoing issue with geckodriver: https://github.com/mozilla/geckodriver/issues/659

If you still want to work with firefox : you can downgrade firefox to v52 and then along with geckodriver v0.15 you'll be able to work fine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.