Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从textbox webdriver java获取文本值_Java_Selenium Webdriver - Fatal编程技术网

从textbox webdriver java获取文本值

从textbox webdriver java获取文本值,java,selenium-webdriver,Java,Selenium Webdriver,我需要从文本框中获取文本值。我尝试使用gettext(),但它给了我空值。请建议如何从文本框中获取电子邮件地址值 当你问问题时,总是插入你的尝试。不要插入图像来显示代码(或html)。更喜欢直接插入代码。使用您的共享信息,感兴趣的web元素的id为EmailAddress。因此,您可以尝试: findElement(By.id("EmailAddress")).getText(); 尝试使用getAttribute:findElement(By.id(“EmailAddress”)).getA

我需要从文本框中获取文本值。我尝试使用gettext(),但它给了我空值。请建议如何从文本框中获取电子邮件地址值

当你问问题时,总是插入你的尝试。不要插入图像来显示代码(或html)。更喜欢直接插入代码。使用您的共享信息,感兴趣的web元素的id为
EmailAddress
。因此,您可以尝试:

findElement(By.id("EmailAddress")).getText();

尝试使用
getAttribute
findElement(By.id(“EmailAddress”)).getAttribute(“value”)

基于
WebElement
getText()
文档:

/**
   * Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements,
   * without any leading or trailing whitespace.
   *
   * @return The innerText of this element.
   */
  String getText();

因此,
bar
getText()
将为您提供
“bar”

您尝试了什么?在问题中插入您的代码。对不起,我尝试了与您提到的完全相同的代码。findElement(By.id(“EmailAddress”)).getText();但它给了我一个空值。您可以在代码中看到它没有文本值,这是一个带有AngularJS的MVC页面。他们从Angular JS获取值,并直接在文本字段上显示@Davide Patti