我正在研究selenium ...我能够在fb和gmail中找到元素,当我尝试使用我的项目运行相同的代码时,我得到一个错误,因为元素不可见。我的错误是:
线程“main”
org.openqa.selenium.ElementNotVisibleException
中的异常:元素不可见
当我尝试找到elementByName
或elementByID
driver.findElement(By.id("j_username")).sendKeys("abhinai");
或
driver.findElement(By.name("j_username")).sendKeys("abhinai");
使用firebug工具时查找元素的代码是
<div class="dijit dijitReset dijitInline dijitLeft dijitTextBox dijitValidationTextBox dijitTextBoxError dijitValidationTextBoxError dijitError dijitTextBoxHover dijitValidationTextBoxHover dijitTextBoxErrorHover dijitValidationTextBoxErrorHover dijitErrorHover dijitHover" id="widget_firstName" role="presentation" lang="en" widgetid="firstName"><div class="dijitReset dijitValidationContainer"><input class="dijitReset dijitInputField dijitValidationIcon dijitValidationInner" value="Χ " type="text" tabindex="-1" readonly="readonly" role="presentation"></div><div class="dijitReset dijitInputField dijitInputContainer"><input class="dijitReset dijitInputInner" data-dojo-attach-point="textbox,focusNode" autocomplete="off" name="firstName" type="text" tabindex="0" aria-required="true" id="firstName" placeholder="required" value="" aria-invalid="true"></div></div>
<div class="dijitReset dijitValidationContainer"><input class="dijitReset dijitInputField dijitValidationIcon dijitValidationInner" value="Χ " type="text" tabindex="-1" readonly="readonly" role="presentation"></div>
<input class="dijitReset dijitInputField dijitValidationIcon dijitValidationInner" value="Χ " type="text" tabindex="-1" readonly="readonly" role="presentation"> </div>
<div class="dijitReset dijitInputField dijitInputContainer"><input class="dijitReset dijitInputInner" data-dojo-attach-point="textbox,focusNode" autocomplete="off" name="firstName" type="text" tabindex="0" aria-required="true" id="firstName" placeholder="required" value="" aria-invalid="true"></div>
<input class="dijitReset dijitInputInner" data-dojo-attach-point="textbox,focusNode" autocomplete="off" name="firstName" type="text" tabindex="0" aria-required="true" id="firstName" placeholder="required" value="" aria-invalid="true"> </div>
任何人都可以帮助我