0

I am using the below to enter a text in the text box:

driver.findElement(By.xpath("//input[@name = 'c_1']")).sendKeys("Test");

HTML:

<div id="ext-comp-1110" class=" x-panel criterion-block" style="width: 252px;">
<div id="ext-gen397" class="x-panel-bwrap">
    <div id="ext-gen398" class="x-panel-body x-panel-body-noheader" style="width: 252px;">
        <div id="ext-comp-1111" class=" x-panel criterion-label">
            <div id="ext-gen413" class="x-panel-bwrap">
                <div id="ext-gen414" class="x-panel-body x-panel-body-noheader">
                    <label id="ext-comp-1112">Insured Name contains:</label>
                </DIV>
            </DIV>
        </DIV>
        <input id="ext-gen186" class=" x-form-text x-form-field criterion " type="text" name="c_1" autocomplete="off" size="20" style="width: 222px;" title="">
    </DIV>
</DIV>

When I run this I get a element not visible exception.

Srivardhan
  • 104
  • 1
  • 3
  • 10

2 Answers2

0

it normally happens when the element is hidden or is sourrounded by a hidden element like a <div>. Selenium Webdriver can only handle it if they are visible. (I did it with Javascript -> refer to the link)

look here how to handle hidden elements

Community
  • 1
  • 1
Leonard Arnold
  • 646
  • 3
  • 14
  • It is not hidden or surrounded with any DIV which is hidden. The same thing can be achieved when I do with ID but this ID changes on every refresh so doing it with Name – Srivardhan Aug 21 '13 at 14:54
  • Check what you receive with `driver.findElement(By.xpath("//input[@name = 'c_1']")).isDisplayed();` – ievche Aug 21 '13 at 14:58
  • There are 2 object when i check the size but when i check is displayed i get false – Srivardhan Aug 22 '13 at 06:09
0

Try something like;

driver.findElement(By.xpath("//div[@id='ext-comp-1112']/../../following-sibling::input"))

if you want to use the label text;

driver.findElement(By.xpath("//div[text()='Insured Name contains:']/../../following-sibling::input"))

NB. I have written this from memory so it may need a tweak but you should get the idea

Robbie Wareham
  • 3,380
  • 1
  • 20
  • 38