Selenium - Navigation gets stuck after clicking a drop down (prior to an iframe switch) - selenium

The code clicks and pops up an overlay (successful). I am able to switch to iframe (using the driver.switchTo().frame(2)). Once selecting an element and clicking the Accept button, the overlay closes. Now I switch back to the main page using driver.switchTo().defaultContent(). The problem occurs soon after the code clicks a dropdown in the main page. This dropdown is not the typical Select or Option type (Select() or <option>). The elements are listed in a <table>.
There is no error displayed in the console but the program hangs. It stops the navigation after clicking the drop down and then no response.
Please find the html portion:
<input type="hidden" name="ctl00$cph$ctl02$TEST$FORM$ctl06$ctl32$ctl01$ctl03"
id="ctl00_cph_ctl02_TEST_FORM_ctl06_ctl32_ctl01_ctl03" />
<input type="hidden" name="ctl00$cph$ctl02$TEST$FORM$ctl06$ctl32$ctl01$ctl04"
id="ctl00_cph_ctl02_TEST_FORM_ctl06_ctl32_ctl01_ctl04" value="-1" />
<input type="hidden" name="ctl00$cph$ctl02$TEST$FORM$ctl06$ctl32$ctl01$ctl05" />
<input type="hidden" name="ctl00$cph$ctl02$TEST$FORM$ctl06$ctl32$ctl01$ctl06" />
<div id="ctl00_cph_ctl02_TEST_FORM_ctl06_ctl32_ctl01_outerFrame"
class="DropdownOuterContainer theme2 boarderA font7 shadow1" style="display:none;">
<div id="ctl00_cph_ctl02_TEST_FORM_ctl06_ctl32_ctl01_innerFrame"
class="DropdownInnerContainer" style="z-index:99;">
<table id="ctl00_cph_ctl02_TEST_FORM_ctl06_ctl32_ctl01_tbl"
class="DropdownItemContainer" list="120">
<tr class="">
<td value="" index="0" title="">
</td>
<td class="BorderCell"></td>
</tr>
<tr class="">
<td value="Act1" index="1" plid="1001">Act1</td>
<td class="BorderCell"></td>
</tr>
<tr class="">
<td value="Act2" index="2" plid="1002">Act2</td>
<td class="BorderCell"></td>
</tr>
<tr class="">
<td value="Act3" index="3" plid="1003">Act3</td>
<td class="BorderCell"></td>
</tr>
<tr class="">
<td value="Act4" index="4" plid="1004">Act4</td>
<td class="BorderCell"></td>
</tr>
</table>
In the code I am trying to select an option 'Act1' using the below statements. Note that only the first line executes, i.e, it clicks the drop down but then it doesn't move forward to the next step, where the selection happens.
driver.findElement(By.xpath(".//*[#id='ctl00_cph_ctl02_TEST$FORM_ctl06_ctl32_ctl01']")).click();
driver.findElement(By.xpath(".//*[#id='ctl00_cph_ctl02_TEST$FORM_ctl06_ctl32_ctl01_tbl']/tbody/tr/td[1][contains(text(),'Act1')]")).click();

Related

How can I add info icon with details next to input fields?

My input fields look like this:
<table class="something">
<tbody>
<tr>
<td style="vertical-align:top;width:60%;padding-right:25px">
<label><i class="far fa-calendar-alt"></i> Something:</label> (<em>something</em>) </td>
<td style="vertical-align:top;width:20%">
<label class="something" for="something">something:</label>
<input id="something" name="something" step="any" type="number" value=""> </td>
</tr>
</tbody>
</table>
How can I add an info icon with some text next to my inputs? I've found some solutions, but those are not fully responsive, they didn't work in all devices. A good example of what I want: https://bankmonitor.hu/lakashitel-kalkulator/?link_type=tile-menu-item
Thank you!

TD not aligned correctly

Im having a little trouble trying to align this table, also the padding is not working. Im trying to make the textbox start in the same position as the checkbox but below it, also im trying to add padding to the first tr by doing it to the td but its not working.
<table>
<tr>
<td>
<input type="checkbox" Style="margin-left: 165px; padding-bottom: 50px;">
</td>
<td>
<label Style="padding-bottom: 50px;">Label for Checkbox</label>
</td>
</tr>
<tr>
<td>
<label Width="163px">#Another Label:</label>
</td>
<td>
<input type="textbox" MaxLength="20" Width="163px">
</td>
</tr>
</table>
Here is the fiddle --> https://jsfiddle.net/u5vu5mn6/

click on a checkbox selenium java

Hi, I want to b able to click on a check box based on a value. Below is the html of the same:
<tbody>
<tr>
<th>Record Type</th>
<th style="text-align:center">Has Access?</th>
<th style="text-align:center">Can Create?</th>
<th style="text-align:center">Can Read All Records?</th>
</tr>
<tr>
<td>
<input id="ORMW.S2.0.Object Type" class="readOnlyField" type="text" value="Account" maxlength="255" size="25" name="ORMW.S2.0.Object Type" readonly="readonly"/>
</td>
<td align="center">
<input id="ORMW.S2.0.Has Access_VP123456" type="checkbox" onclick="cbValue(this,'ORMW.S2.0.Has\x20Access');" style="margin-left:0px;margin-top:1px;height:10px;width:10px;vertical-align:middle"/>
<input id="ORMW.S2.0.Has Access" type="hidden" value="Y" tabindex="-1" name="ORMW.S2.0.Has Access"/>
</td>
<td align="center">
<td align="center">
I want to click on checkbox based on the value account here.
Next query will search element by #value='Account' then traverse up to the first tr and then search your checkbox:
//input[#type='text' and #value='Account']/ancestor::tr[1]//input[#type='checkbox']
you can also try this:
//input[#type='checkbox' and preceding-sibling::input[#type='text' and #value='Account']]

Auto login form with Visual Basic

I need make an auto login form application with Visual Basic 10.0 for the following code:
</script>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
<table cellpadding="0" cellspacing="0" border="0" height="100%">
<tr>
<td rowspan="10" width="50%" height="100%" background="images/bg1222.jpg" style="background-position:right top; background-repeat:repeat-y"></td>
<td rowspan="10" width="1" bgcolor="#000000"></td>
<td valign="top">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td width=100%>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="778" height="153">
<param name="movie" value="images/hed2.swf">
<param name="quality" value="high">
<embed src="images/hed2.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="778" height="153"></embed>
</object>
</td>
</tr>
</table>
</td>
<!--<td rowspan="10" width="0" bgcolor="#000000"></td>-->
<td rowspan="10" width="50%" height="100%" background="images/bg1223.jpg" style="background-position:left top; background-repeat:repeat-y"></td>
</tr>
<tr>
<td width="780" height="30" align="center" valign="bottom" background="images/footer.gif"></td>
</tr>
<tr>
<td height="583" valign="top" style="background-repeat:repeat-y;" >
<br><br><br><br><br><br><br>
<center>
<form action="/cse/login/login1_check.jsp" name="first" method="post">
<table width="25%" height="90" border="0" class='formtable1'>
<caption align="top">
<strong> User Login </strong>
<br>
</caption>
<tr>
</tr>
<tr>
<td width="24%" height="32">
<div align="right"> User ID: </div>
</td>
<td width="76%">
<label>
<input name="uid" type="text" >
</label>
</td>
</tr>
<tr>
<td height="43">
<div align="right"> Password: </div>
</td>
<td>
<label>
<input name="password" type="password" >
</label>
</td>
</tr>
</table>
<input type="submit" name="sub" value="Login">
</form>
</center>`enter code here`
Say username is user and password is pass.
It should be auto filled and clicked in the submit button. What would the code be for Visual Basic 10.0?
Try this:
If Not String.IsNullOrEmpty(My.Settings.Username) And Not String.IsNullOrEmpty(My.Settings.Password) Then
TxtUsername.Text = My.Settings.Username
TxtPassword.Text = My.Settings.Password
End If
You first need to take all the elements that you want to interact to. If they have an ID, you don't need to search, simply get the element with:
Dim elem As HtmlElement = Webbrowser1.Document.GetElementById("myId")
If not, you need to search for yours, for example:
Dim inputs As New List(Of HtmlElement)(a.Document.GetElementsByTagName("input"))
For Each elem As HtmlElement In inputs
If elem.GetAttribute("name").Equals("uid") Then
'...
End If
Next
To set a value of a input:
elem.SetAttributte("value", passwordVar)
To click a clickable element (such a submit input):
elem.InvokeMember("submit")
Or:
elem.InvokeMember("click")

Input field is filled, but content is not saved using Selenium IDE

Using Selenium IDE, I'm able to fill an input field (using "type" command), but when I "save" the value, this value is lost. Doing the same by hand, everything works fine.
Any hint to solve this issue? I've already tried using typeKeys command.
The code inside the target page is:
<!-- language-all: lang-html -->
<div id="editDiv" class="editDialog">
<table cellspacing="0" width="100%">
<tbody>
<tr>
<td width="25%" style="">period</td>
<td align="right" width="25%" style="padding: 6px;">
<input id="period" type="text" onblur="changeValue(this.id, this.value, undefined)">
<br>
<label>da 0 a 9</label>
</td>
</tr>
</tbody>
</table>
<table cellspacing="0" width="100%">
<input type="button" value="Save" onclick="applyChanges()">
<input type="button" value="Cancel" onclick="removeEditDialog(false)">
</div>
To help more on this issue:
function changeValue(id, value, paramPos) {
var par = tempGlobalParams[id] ? tempGlobalParams[id] : tempGlobalPaintingsParams[paramPos][id];
if(checkRules(id, value, paramPos)){
par.custom = value;
}