如何使用Selenium在文本字段中发送数据? [英] How can I send data in text field using Selenium?

查看:477
本文介绍了如何使用Selenium在文本字段中发送数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在文本字段中发送数据时遇到问题。我有一个例外。

我使用Firefox版本54.0b1(32-bit)和Selenium 3.3.1。

  driver.findElement(By.xpath(.//*[@id ='email']))。sendKeys(Test); 

例外:

lockquote

线程main中的异常org.openqa.selenium.InvalidArgumentException:期望[object Undefined] undefined是一个字符串


解决方案

您需要为Mozilla Firefox 54.x和Selenium 3.x下载最新的gecko驱动程序。 同时提供准确的路径如下所示:

  System.setProperty(webdriver.gecko.driver,C:\\directory\\\ \\geckodriver.exe); 
WebDriver driver = new FirefoxDriver();
driver.manage()。window()。maximize();
driver.get(http:\\yoururl.com);
driver.manage()。timeouts()。implicitlyWait(5,TimeUnit.SECONDS);
driver.findElement(By.xpath(.//*[@id ='email']))。sendKeys(Test);

希望它能为您服务。


I'm having an issue when I'm going to send data in text field. I got an exception.

I'm using Firefox version 54.0b1 (32-bit) and Selenium 3.3.1.

driver.findElement(By.xpath(".//*[@id='email']")).sendKeys("Test");

The exception:

Exception in thread "main" org.openqa.selenium.InvalidArgumentException: Expected [object Undefined] undefined to be a string

解决方案

you need to download the latest gecko driver for Mozilla Firefox 54.x and Selenium 3.x.

Also provide accurate path as follows:

        System.setProperty("webdriver.gecko.driver", "C:\\directory\\geckodriver.exe");
        WebDriver driver =  new FirefoxDriver();
        driver.manage().window().maximize();
        driver.get("http:\\yoururl.com");
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        driver.findElement(By.xpath(".//*[@id='email']")).sendKeys("Test");

Hope it will work for you.

这篇关于如何使用Selenium在文本字段中发送数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆