selenium - Not able to click the button after entering value in textarea Options -


code used is:

webelement desc=driver.findelementbyxpath(".//*[@label='description']");   desc.sendkeys("testing");  desc.sendkeys(keys.enter);    list<webelement> button=driver.findelementsbyxpath("(//div[@id='sv'])[1]");    (webelement buttonname : button)   {           system.out.println("buttonname: "+buttonname.getattribute("id"));           string = buttonname.getattribute("id");           driver.findelementbyid(but).click();   } 

below html code of textarea , button .

<td> <textarea id="1992800000" label="description" ft="12" mand="false"class="ic" maxlength="120" cols="13" rows="2"/> </td>  ......  <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 40px; "> <td class="pdl"> <div class="tbut" onclick="ir('tas','tas','')" id="sv">save</div> </td>  

your xpath can select 1 element, there no need create list , iterate through it. try more like:

webelement desc=driver.findelementbyxpath("//*[@label='description']");  desc.sendkeys("testing");   webelement button=driver.findelementsbyxpath("(//div[@id='sv'])[1]"); button.click(); 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -