I am new to selenium, trying to automate a webpage form. Using Excel 2016 with VBA and Chrome browser.
The particular page requires login credentials, so unable to share the URL where this error happens.
There are couple of dropdown items, which I am having trouble with. I get Selenium Error, Element not interactable. Below is one such element. Sorry, I am not able to get the complete HTML code here.
<div class="col-md-2">
<select name="ctl00$MainContent$ddlScopeYear" id="MainContent_ddlScopeYear" class="chosen-select select_styled" style="display: none;">
<option selected="selected" value="--Select--">--Select--</option>
<option value="2021">2021</option>
<option value="2020">2020</option>
<option value="2019">2019</option>
<option value="2018">2018</option>
<option value="2017">2017</option>
<option value="2016">2016</option>
<option value="2015">2015</option>
<option value="2014">2014</option>
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
<option value="2000">2000</option>
<option value="1999">1999</option>
<option value="1998">1998</option>
<option value="1997">1997</option>
<option value="1996">1996</option>
<option value="1995">1995</option>
<option value="1994">1994</option>
<option value="1993">1993</option>
<option value="1992">1992</option>
<option value="1991">1991</option>
<option value="1990">1990</option>
<option value="1989">1989</option>
<option value="1988">1988</option>
<option value="1987">1987</option>
<option value="1986">1986</option>
<option value="1985">1985</option>
<option value="1984">1984</option>
<option value="1983">1983</option>
<option value="1982">1982</option>
<option value="1981">1981</option>
<option value="1980">1980</option>
<option value="1979">1979</option>
<option value="1978">1978</option>
<option value="1977">1977</option>
<option value="1976">1976</option>
<option value="1975">1975</option>
<option value="1974">1974</option>
<option value="1973">1973</option>
<option value="1972">1972</option>
<option value="1971">1971</option>
<option value="1970">1970</option>
<option value="1969">1969</option>
<option value="1968">1968</option>
<option value="1967">1967</option>
<option value="1966">1966</option>
<option value="1965">1965</option>
<option value="1964">1964</option>
<option value="1963">1963</option>
<option value="1962">1962</option>
<option value="1961">1961</option>
<option value="1960">1960</option>
<option value="1959">1959</option>
<option value="1958">1958</option>
<option value="1957">1957</option>
<option value="1956">1956</option>
<option value="1955">1955</option>
<option value="1954">1954</option>
<option value="1953">1953</option>
<option value="1952">1952</option>
<option value="1951">1951</option>
<option value="1950">1950</option>
<option value="1949">1949</option>
<option value="1948">1948</option>
<option value="1947">1947</option>
<option value="1946">1946</option>
<option value="1945">1945</option>
<option value="1944">1944</option>
<option value="1943">1943</option>
<option value="1942">1942</option>
<option value="1941">1941</option>
<option value="1940">1940</option>
<option value="1939">1939</option>
<option value="1938">1938</option>
<option value="1937">1937</option>
<option value="1936">1936</option>
<option value="1935">1935</option>
<option value="1934">1934</option>
<option value="1933">1933</option>
<option value="1932">1932</option>
<option value="1931">1931</option>
<option value="1930">1930</option>
<option value="1929">1929</option>
<option value="1928">1928</option>
<option value="1927">1927</option>
<option value="1926">1926</option>
<option value="1925">1925</option>
<option value="1924">1924</option>
<option value="1923">1923</option>
<option value="1922">1922</option>
<option value="1921">1921</option>
<option value="1920">1920</option>
<option value="1919">1919</option>
<option value="1918">1918</option>
<option value="1917">1917</option>
<option value="1916">1916</option>
<option value="1915">1915</option>
<option value="1914">1914</option>
<option value="1913">1913</option>
<option value="1912">1912</option>
<option value="1911">1911</option>
<option value="1910">1910</option>
<option value="1909">1909</option>
<option value="1908">1908</option>
<option value="1907">1907</option>
<option value="1906">1906</option>
<option value="1905">1905</option>
<option value="1904">1904</option>
<option value="1903">1903</option>
<option value="1902">1902</option>
<option value="1901">1901</option>
<option value="1900">1900</option>
</select><div class="chosen-container chosen-container-single chosen-container-active" style="width:100%;" title="" id="MainContent_ddlScopeYear_chosen"><a class="chosen-single"><span>2021</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off"></div><ul class="chosen-results"><li class="active-result" data-option-array-index="0" style="">--Select--</li><li class="active-result result-selected" data-option-array-index="1" style="">2021</li><li class="active-result" data-option-array-index="2" style="">2020</li><li class="active-result" data-option-array-index="3" style="">2019</li><li class="active-result" data-option-array-index="4" style="">2018</li><li class="active-result" data-option-array-index="5" style="">2017</li><li class="active-result" data-option-array-index="6" style="">2016</li><li class="active-result" data-option-array-index="7" style="">2015</li><li class="active-result" data-option-array-index="8" style="">2014</li><li class="active-result" data-option-array-index="9" style="">2013</li><li class="active-result" data-option-array-index="10" style="">2012</li><li class="active-result" data-option-array-index="11" style="">2011</li><li class="active-result" data-option-array-index="12" style="">2010</li><li class="active-result" data-option-array-index="13" style="">2009</li><li class="active-result" data-option-array-index="14" style="">2008</li><li class="active-result" data-option-array-index="15" style="">2007</li><li class="active-result" data-option-array-index="16" style="">2006</li><li class="active-result" data-option-array-index="17" style="">2005</li><li class="active-result" data-option-array-index="18" style="">2004</li><li class="active-result" data-option-array-index="19" style="">2003</li><li class="active-result" data-option-array-index="20" style="">2002</li><li class="active-result" data-option-array-index="21" style="">2001</li><li class="active-result" data-option-array-index="22" style="">2000</li><li class="active-result" data-option-array-index="23" style="">1999</li><li class="active-result" data-option-array-index="24" style="">1998</li><li class="active-result" data-option-array-index="25" style="">1997</li><li class="active-result" data-option-array-index="26" style="">1996</li><li class="active-result" data-option-array-index="27" style="">1995</li><li class="active-result" data-option-array-index="28" style="">1994</li><li class="active-result" data-option-array-index="29" style="">1993</li><li class="active-result" data-option-array-index="30" style="">1992</li><li class="active-result" data-option-array-index="31" style="">1991</li><li class="active-result" data-option-array-index="32" style="">1990</li><li class="active-result" data-option-array-index="33" style="">1989</li><li class="active-result" data-option-array-index="34" style="">1988</li><li class="active-result" data-option-array-index="35" style="">1987</li><li class="active-result" data-option-array-index="36" style="">1986</li><li class="active-result" data-option-array-index="37" style="">1985</li><li class="active-result" data-option-array-index="38" style="">1984</li><li class="active-result" data-option-array-index="39" style="">1983</li><li class="active-result" data-option-array-index="40" style="">1982</li><li class="active-result" data-option-array-index="41" style="">1981</li><li class="active-result" data-option-array-index="42" style="">1980</li><li class="active-result" data-option-array-index="43" style="">1979</li><li class="active-result" data-option-array-index="44" style="">1978</li><li class="active-result" data-option-array-index="45" style="">1977</li><li class="active-result" data-option-array-index="46" style="">1976</li><li class="active-result" data-option-array-index="47" style="">1975</li><li class="active-result" data-option-array-index="48" style="">1974</li><li class="active-result" data-option-array-index="49" style="">1973</li><li class="active-result" data-option-array-index="50" style="">1972</li><li class="active-result" data-option-array-index="51" style="">1971</li><li class="active-result" data-option-array-index="52" style="">1970</li><li class="active-result" data-option-array-index="53" style="">1969</li><li class="active-result" data-option-array-index="54" style="">1968</li><li class="active-result" data-option-array-index="55" style="">1967</li><li class="active-result" data-option-array-index="56" style="">1966</li><li class="active-result" data-option-array-index="57" style="">1965</li><li class="active-result" data-option-array-index="58" style="">1964</li><li class="active-result" data-option-array-index="59" style="">1963</li><li class="active-result" data-option-array-index="60" style="">1962</li><li class="active-result" data-option-array-index="61" style="">1961</li><li class="active-result" data-option-array-index="62" style="">1960</li><li class="active-result" data-option-array-index="63" style="">1959</li><li class="active-result" data-option-array-index="64" style="">1958</li><li class="active-result" data-option-array-index="65" style="">1957</li><li class="active-result" data-option-array-index="66" style="">1956</li><li class="active-result" data-option-array-index="67" style="">1955</li><li class="active-result" data-option-array-index="68" style="">1954</li><li class="active-result" data-option-array-index="69" style="">1953</li><li class="active-result" data-option-array-index="70" style="">1952</li><li class="active-result" data-option-array-index="71" style="">1951</li><li class="active-result" data-option-array-index="72" style="">1950</li><li class="active-result" data-option-array-index="73" style="">1949</li><li class="active-result" data-option-array-index="74" style="">1948</li><li class="active-result" data-option-array-index="75" style="">1947</li><li class="active-result" data-option-array-index="76" style="">1946</li><li class="active-result" data-option-array-index="77" style="">1945</li><li class="active-result" data-option-array-index="78" style="">1944</li><li class="active-result" data-option-array-index="79" style="">1943</li><li class="active-result" data-option-array-index="80" style="">1942</li><li class="active-result" data-option-array-index="81" style="">1941</li><li class="active-result" data-option-array-index="82" style="">1940</li><li class="active-result" data-option-array-index="83" style="">1939</li><li class="active-result" data-option-array-index="84" style="">1938</li><li class="active-result" data-option-array-index="85" style="">1937</li><li class="active-result" data-option-array-index="86" style="">1936</li><li class="active-result" data-option-array-index="87" style="">1935</li><li class="active-result" data-option-array-index="88" style="">1934</li><li class="active-result" data-option-array-index="89" style="">1933</li><li class="active-result" data-option-array-index="90" style="">1932</li><li class="active-result" data-option-array-index="91" style="">1931</li><li class="active-result" data-option-array-index="92" style="">1930</li><li class="active-result" data-option-array-index="93" style="">1929</li><li class="active-result" data-option-array-index="94" style="">1928</li><li class="active-result" data-option-array-index="95" style="">1927</li><li class="active-result" data-option-array-index="96" style="">1926</li><li class="active-result" data-option-array-index="97" style="">1925</li><li class="active-result" data-option-array-index="98" style="">1924</li><li class="active-result" data-option-array-index="99" style="">1923</li><li class="active-result" data-option-array-index="100" style="">1922</li><li class="active-result" data-option-array-index="101" style="">1921</li><li class="active-result" data-option-array-index="102" style="">1920</li><li class="active-result" data-option-array-index="103" style="">1919</li><li class="active-result" data-option-array-index="104" style="">1918</li><li class="active-result" data-option-array-index="105" style="">1917</li><li class="active-result" data-option-array-index="106" style="">1916</li><li class="active-result" data-option-array-index="107" style="">1915</li><li class="active-result" data-option-array-index="108" style="">1914</li><li class="active-result" data-option-array-index="109" style="">1913</li><li class="active-result" data-option-array-index="110" style="">1912</li><li class="active-result" data-option-array-index="111" style="">1911</li><li class="active-result" data-option-array-index="112" style="">1910</li><li class="active-result" data-option-array-index="113" style="">1909</li><li class="active-result" data-option-array-index="114" style="">1908</li><li class="active-result" data-option-array-index="115" style="">1907</li><li class="active-result" data-option-array-index="116" style="">1906</li><li class="active-result" data-option-array-index="117" style="">1905</li><li class="active-result" data-option-array-index="118" style="">1904</li><li class="active-result" data-option-array-index="119" style="">1903</li><li class="active-result" data-option-array-index="120" style="">1902</li><li class="active-result" data-option-array-index="121" style="">1901</li><li class="active-result" data-option-array-index="122" style="">1900</li></ul></div></div>
<span id="MainContent_RequiredFieldValidator2" style="color:Red;visibility:hidden;">Required</span>
</div>
<select name="ctl00$MainContent$ddlscopegroupp" onchange="javascript:setTimeout('__doPostBack(\'ctl00$MainContent$ddlscopegroupp\',\'\')', 0)" id="MainContent_ddlscopegroupp" class="chosen-select select_styled" style="display: none;">
<option selected="selected" value="0">--Select Product Material--</option>
<option value="Others">Others</option>
</select>
<div class="chosen-container chosen-container-single chosen-with-drop chosen-container-active" style="width:100%;" title="" id="MainContent_ddlscopegroupp_chosen"><a class="chosen-single"><span>--Select Product Material--</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off"></div><ul class="chosen-results"><li class="active-result result-selected highlighted" data-option-array-index="0" style="">--Select Product Material--</li><li class="active-result" data-option-array-index="1" style="">Others</li></ul></div></div>
I am using VBA, code below:
Sub t1()
Dim Driver As New Selenium.ChromeDriver
Set Driver = CreateObject("Selenium.ChromeDriver")
Driver.Get "https://nablwp.qci.org.in/Test-Lab/ScopeOfAccreditation"
Driver.FindElementById("MainContent_btnViewScope").Click
Driver.FindElementById("MainContent_ddlScopeDisci").SendKeys "Electronics"
Driver.FindElementById("MainContent_ddlScopeGroup").SendKeys "EMC Test Facility"
Driver.FindElementById("MainContent_ddlsbGrp").SendKeys "Radiated Emission Test"
Driver.FindElementById("MainContent_txtScopeStand").ScrollIntoView
SetCursorPos 700, 710
SingleClick
SetCursorPos 700, 860
SingleClick
'Below element is another uninteractable one. I am managing it with a mouse click. Luckily, it has only one option in the dropdown, so mouse click works.
Driver.FindElementById("MainContent_txtScopeGroup").SendKeys "IT"
Driver.FindElementById("MainContent_txtScopeTestPer").SendKeys "Radiated Emission Test"
Driver.FindElementById("MainContent_txtScopeStand").SendKeys "CISPR 32:2015/AMD1"
Driver.FindElementById("MainContent_txtScopeRangeRem").ScrollIntoView
SetCursorPos 800, 800
SingleClick
SetCursorPos 800, 940
SingleClick
'Below element is another uninteractable one. Mouse click method does not work here, as it has options from year 1900 to 2021!!!
Driver.FindElementByCss("input#MainContent_ddlScopeYear_chosen").SendKeys "2019"
Driver.FindElementById("MainContent_ddlRangeType").SendKeys "Quantitative"
Driver.FindElementById("MainContent_txtScopeRangeLL").SendKeys "30"
Driver.FindElementById("MainContent_btnllUnit").Click
Driver.FindElementById("MainContent_htmext1_ExtenderCOntentEditable").SendKeys "MHz"
Driver.FindElementById("MainContent_btnShowLL").Click
End Sub'
I am stepping through the code, and it still does not work, so it does not appear to be time related that can be solved by Wait.
"Display: none" property seems to be creating the issue, need help in solving it in VBA. Thank you.
Related
When loading selectize selects inside a table, the table automatically reduces the cell width to the miminum size possible squeezing selectize dropdowns. When you open dropdown, the options are illegible - the first 3-4 characters can be read and the rest are hidden.
Here is a sample fiddle:
$(function() {
$('select').selectize({ plugins: ['remove_button']
});
<form role="form" id="contacts">
<table>
<tr><td> <select placeholder="Select a person..." multiple>
<option value="">All</option>
<option value="4">Thomas Edison</option>
<option value="17">John Doe</option>
<option value="19">John Donut</option>
<option value="21">Dante Joe</option>
<option value="22">Jo Dod</option>
<option value="1">Nikola</option>
<option value="3">Nikola Tesla</option>
<option value="5">Arnold Schwarzenegger</option>
</select></td>
<td> <select placeholder="Select a person..." multiple>
<option value="">All</option>
<option value="4">Thomas Edison</option>
<option value="17">John Doe</option>
<option value="19">John Donut</option>
<option value="21">Dante Joe</option>
<option value="22">Jo Dod</option>
<option value="1">Nikola</option>
<option value="3">Nikola Tesla</option>
<option value="5">Arnold Schwarzenegger</option>
</select></td>
<td> <select placeholder="Select a person..." multiple>
<option value="">All</option>
<option value="4">Thomas Edison</option>
<option value="17">John Doe</option>
<option value="19">John Donut</option>
<option value="21">Dante Joe</option>
<option value="22">Jo Dod</option>
<option value="1">Nikola</option>
<option value="3">Nikola Tesla</option>
<option value="5">Arnold Schwarzenegger</option>
</select></td>
<td> <select placeholder="Select a person..." multiple>
<option value="">All</option>
<option value="4">Thomas Edison</option>
<option value="17">John Doe</option>
<option value="19">John Donut</option>
<option value="21">Dante Joe</option>
<option value="22">Jo Dod</option>
<option value="1">Nikola</option>
<option value="3">Nikola Tesla</option>
<option value="5">Arnold Schwarzenegger</option>
</select></td> <td> <select placeholder="Select a person..." multiple>
<option value="">All</option>
<option value="4">Thomas Edison</option>
<option value="17">John Doe</option>
<option value="19">John Donut</option>
<option value="21">Dante Joe</option>
<option value="22">Jo Dod</option>
<option value="1">Nikola</option>
<option value="3">Nikola Tesla</option>
<option value="5">Arnold Schwarzenegger</option>
</select></td> <td> <select placeholder="Select a person..." multiple>
<option value="">All</option>
<option value="4">Thomas Edison</option>
<option value="17">John Doe</option>
<option value="19">John Donut</option>
<option value="21">Dante Joe</option>
<option value="22">Jo Dod</option>
<option value="1">Nikola</option>
<option value="3">Nikola Tesla</option>
<option value="5">Arnold Schwarzenegger</option>
</select></td> <td> <select placeholder="Select a person..." multiple>
<option value="">All</option>
<option value="4">Thomas Edison</option>
<option value="17">John Doe</option>
<option value="19">John Donut</option>
<option value="21">Dante Joe</option>
<option value="22">Jo Dod</option>
<option value="1">Nikola</option>
<option value="3">Nikola Tesla</option>
<option value="5">Arnold Schwarzenegger</option>
</select></td></tr>
</table>
</form>
https://jsfiddle.net/csjqaf3m/
As you can see, the items in the list are completely illegible.
My columns cannot have fixed widths because the data loaded into them varies - in one instance, I could have 3 options with max 6 characters, next could load in data with up 15 characters width ...
Not overly concerned about the width of the dropdown BUT when it is open, I expect the select to show all data and make sure it can be read and is visible...
Insert a min-width for dropdown
.selectize-dropdown{
min-width:250px !important;
}
I was hoping there was an option or method that existed to make this work but apparently not so I designed a solution which isn't perfect but it's as close as I think I'm going to get.
When creating the dropdown I use jQuery to test the length of every item in the dropdown and store the largest length. I then pad out the default select option with dashes so that the length matches the largest element:
var optionLength = 0;
this
.data()
.sort()
.unique()
.each( function(d) {
// Get the length of the longest
optionLength = (d.length>optionLength?d.length:optionLength);
select.append($('<option>' + d + '</option>'));
} );
var spacer = "-".repeat(optionLength/2);
select.prepend('<option value="">'+spacer+' All '+spacer+'</option>');
I want to study crawling with selenium and beautiful soup.
I did successfully accessing the website and logged in.
And I tried to get some value by text but it doesn't work.
This is the code that I made.
all3=soup.find("td",{"class": " text-right txt-r"}).text
print(all3)
all4=soup.find("td",{"class": " text-right txt-r"}).text
print(all4)
This is the website coding as follows. I want to get the value from 1st to 4th values by text. However, td class name is same, so I don't know how to get parsing the date with soup.
<td class=" text-right txt-r">7,730</td>
<td class=" text-right txt-r">33,500</td>
<td class=" text-right txt-r">72.8</td>
<td class=" text-right txt-r">88</td>
<td class=" text-right txt-r">0.72%</td>
<td class=" text-right txt-r">0.22%</td>
<td class=" text-center txt-c">높음</td>
<td class=" text-right txt-r">15</td>
I want to make the result as follows.
Print(all3)
Print(all4)
Print(all5)
Print(all6)
7,730, 33,500, 72.8, 88
I have a question I can't seem to figure out the answer to regarding how to dispatch an event in VBA.
On the website I am trying to navigate via VBA, there is a dynamic table id="G_grdProfile". In the table html, there are events listed. The table itself is dynamic. At minimum there will always be a row with the id="grdProfile_r_0". Within that row, there are cells that can be clicked. There can be id="grdProfile_rc_0_0", grdProfile_rc_0_1", etc.
I assume I need to dispatch the event in relation to the row or individual cell within the row, but I can't seem to get it to work. From using developer tools in Chrome and IE, it looks like either the ondblclick or onmousedown events are fired when a cell (other than 17) is clicked.
And .click does not return an error, but does not do anything.
My code is:
With ie
While .Busy Or .ReadyState <> 4: DoEvents: Wend
Application.Wait (Now + TimeValue("0:00:02"))
Set objLink = .Document.frames("mainParent").Document.forms("AgentProfileList").Document.getElementById("G_grdProfile").Document.getElementById("grdProfile_r_0").Document.getElementById("grdProfile_rc_0_2")
objLink.dispatchEvent ("onmousedown")
End With
The HTML referenced above for this section is:
<TABLE onmouseup='igtbl_cellClickUp(event,"grdProfile");' onmouseover='igtbl_cellMouseOver(event,"grdProfile");' ondblclick='igtbl_cellDblClick(event,"grdProfile");' onmousemove='igtbl_cellMouseMove(event,"grdProfile");' onmousedown='igtbl_cellClickDown(event,"grdProfile");' onmouseout='igtbl_cellMouseOut(event,"grdProfile");' id=G_grdProfile onselectstart='igtbl_selectStart(event,"grdProfile");' style="WIDTH: 978px; TABLE-LAYOUT: fixed; POSITION: relative" oncontextmenu='igtbl_cellContextMenu(event,"grdProfile");' cellSpacing=0 cellPadding=0 border=0 bandNo="0"><COLGROUP>
<TR id=grdProfile_r_0 style="HEIGHT: 20px" DataKey="XXXXX3658"><TD id=grdProfile_rc_0_0 class="ig_2e49b359_r1 GRSHand"><NOBR><SPAN id=fup_agentstdsearch_3765545><A onclick='javascript:xfupshow("fup_agentstdsearch_3765545");' href="javascript:void(0);"><IMG border=0 src="https://xchange.reged.com/ctiacom/images/flag000.gif"></A></SPAN> </NOBR></TD>
<TD id=grdProfile_rc_0_1 class="ig_2e49b359_r1 GRSHand" style="DISPLAY: none" iDV="False"><NOBR><INPUT tabIndex=-1 onpropertychange='igtbl_chkBoxChange(event,"grdProfile");' type=checkbox></NOBR></TD>
<TD id=grdProfile_rc_0_2 class="ig_2e49b359_r1 GRSHand"><NOBR>*LastName*</NOBR></TD>
<TD id=grdProfile_rc_0_3 class="ig_2e49b359_r1 GRSHand"><NOBR>*FIrstName*</NOBR></TD>
<TD id=grdProfile_rc_0_4 class="ig_2e49b359_r1 GRSHand"><NOBR>*MiddleName*</NOBR></TD>
<TD id=grdProfile_rc_0_5 class="ig_2e49b359_r1 GRSHand" style="DISPLAY: none"><NOBR>3765545</NOBR></TD>
<TD id=grdProfile_rc_0_6 class="ig_2e49b359_r1 GRSHand"><NOBR>*ID*</NOBR></TD>
<TD id=grdProfile_rc_0_7 class="ig_2e49b359_r1 GRSHand"><NOBR>*ID2*</NOBR></TD>
<TD id=grdProfile_rc_0_8 class="ig_2e49b359_r1 GRSHand"><NOBR> </NOBR></TD>
<TD id=grdProfile_rc_0_9 class="ig_2e49b359_r1 GRSHand"><NOBR>*ID3*</NOBR></TD>
<TD id=grdProfile_rc_0_10 class="ig_2e49b359_r1 GRSHand" style="DISPLAY: none"><NOBR>*ID2*</NOBR></TD>
<TD id=grdProfile_rc_0_11 class="ig_2e49b359_r1 GRSHand" style="DISPLAY: none"><NOBR>*Location*</NOBR></TD>
<TD id=grdProfile_rc_0_12 class="ig_2e49b359_r1 GRSHand" style="DISPLAY: none"><NOBR>PROD</NOBR></TD>
<TD id=grdProfile_rc_0_13 class="ig_2e49b359_r1 GRSHand" style="DISPLAY: none"><NOBR>0</NOBR></TD>
<TD id=grdProfile_rc_0_14 class="ig_2e49b359_r1 GRSHand" style="DISPLAY: none"><NOBR>7040</NOBR></TD>
<TD id=grdProfile_rc_0_15 class="ig_2e49b359_r1 GRSHand" style="DISPLAY: none"><NOBR> </NOBR></TD>
<TD id=grdProfile_rc_0_16 class="ig_2e49b359_r1 GRSHand" style="DISPLAY: none"><NOBR> </NOBR></TD>
<TD id=grdProfile_rc_0_17 class="ig_2e49b359_r1 GRSHand"><NOBR><A onclick="viewProfile('3765545','*LastName* *FirstName*');" href="javascript:void(0);">View Profile Summary</A></NOBR></TD>
<TD id=grdProfile_rc_0_18 class="ig_2e49b359_r1 GRSHand" style="DISPLAY: none"><NOBR> </NOBR></TD>
<TD id=grdProfile_rc_0_19 class="ig_2e49b359_r1 GRSHand" style="DISPLAY: none"><NOBR> </NOBR></TD>
<TD id=grdProfile_rc_0_20 class="ig_2e49b359_r1 GRSHand" style="DISPLAY: none"><NOBR> </NOBR></TD>
<TD id=grdProfile_rc_0_21 class="ig_2e49b359_r1 GRSHand" style="DISPLAY: none"><NOBR> </NOBR></TD></TR>
Any ideas, or am I even using dispatchEvent properly?
I figured out what needed to occur was a few mouse events had to fire to move forward.
I ended up setting the cell in the table that I wanted to click and used fireEvent to fire all of the onmouse* events that had to happen.
Set objLink = IE1.document.frames("mainParent").document.forms("AgentProfileList").document.getElementById("grdProfile_r_0").document.getElementById("grdProfile_rc_0_2")
objLink.fireEvent ("onmouseover")
objLink.fireEvent ("onmousedown")
objLink.fireEvent ("onmouseup")
What Layouts need use for make this?
HTML
<h1>Title</h1>
<div id="itemWrapper">
<div class="item">
<div class="png">
<img src="xxx.png">
</div>
<div class="text">
text text text text text text text text text text
</div>
</div>
<div class="item">
<div class="png">
<img src="xxx.png">
</div>
<div class="text">
text text text text text text text text text text
</div>
</div>
<div class="item">
<div class="png">
<img src="xxx.png">
</div>
<div class="text">
text text text text text text text text text text
</div>
</div>
<div class="item">
<div class="png">
<img src="xxx.png">
</div>
<div class="text">
text text text text text text text text text text
</div>
</div>
</div>
CSS
.item{clear:both;}
.item .png{float:left;height:50px}
.item .text{float:left;height:50px}
h1{text-align:center}
I am automating a site in which I want to click on the links inside a table.
In UI, the table showing like this:
Action Contract Line Item Number Product Product Code
Edit | Del CLI-757042 OpenTable System (Guest Center) SYS010
Edit | Del CLI-757043 Guests Seated from Online GC
I want to click the links CLI-757042,CLI-757043,CLI-757044 one by one. The numbers are random.
Below is the html code:
<!-- WrappingClass -->
<div class="listRelatedObject customnotabBlock"><div class="bPageBlock brandSecondaryBrd secondaryPalette"><div class="pbHeader"> … </div><div id="800f00000006cQt_00Na000000ASdVK_body" class="pbBody"><table class="list" cellspacing="0" cellpadding="0" border="0"><tbody><tr class="headerRow"> … </tr>
<!-- ListRow -->
<tr class="dataRow even first" onmouseover="if (window.hiOn){hiOn(this);}" onmouseout="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}" onblur="if (window.hiOff){hiOff(this);}"><td class="actionColumn"> … </td><th class=" dataCell " scope="row"><a href="/a1if0000000ZfEv">
CLI-757042
</a></th><td class=" dataCell "> … </td><td class=" dataCell "> … </td><td class=" dataCell CurrencyElement"> … </td><td class=" dataCell "> … </td><td class=" dataCell CurrencyElement"> … </td><td class=" dataCell numericalColumn"> … </td><td class=" dataCell numericalColumn"> … </td><td class=" dataCell CurrencyElement"> … </td><td class=" dataCell "> … </td></tr>
<!-- ListRow -->
<tr class="dataRow odd" onmouseover="if (window.hiOn){hiOn(this);}" onmouseout="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}" onblur="if (window.hiOff){hiOff(this);}"><td class="actionColumn"> … </td><th class=" dataCell " scope="row"> … </th><td class=" dataCell "> … </td><td class=" dataCell "> … </td><td class=" dataCell CurrencyElement"> … </td><td class=" dataCell "> … </td><td class=" dataCell CurrencyElement"> … </td><td class=" dataCell numericalColumn"> … </td><td class=" dataCell numericalColumn"> … </td><td class=" dataCell CurrencyElement"> … </td><td class=" dataCell "> … </td></tr>
<!-- ListRow -->
<tr class="dataRow even" onmouseover="if (window.hiOn){hiOn(this);}" onmouseout="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}" onblur="if (window.hiOff){hiOff(this);}"> … </tr>
<!-- ListRow -->
<tr class="dataRow odd" onmouseover="if (window.hiOn){hiOn(this);}" onmouseout="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}" onblur="if (window.hiOff){hiOff(this);}"> … </tr>
<!-- ListRow -->
<tr class="dataRow even last" onmouseover="if (window.hiOn){hiOn(this);}" onmouseout="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}" onblur="if (window.hiOff){hiOff(this);}"> … </tr></tbody></table><div class="pShowMore"> … </div></div><div class="pbFooter secondaryPalette"> … </div></div></div><div class="listElementBottomNav"></div><script> … </script>
<!-- End ListElement -->
</div>
<!-- End RelatedListElement -->
<!-- Begin RelatedListElement -->
<div id="800f00000006cQt_00Na000000ASdVM" class="bRelatedList"><a name="800f00000006cQt_00Na000000ASdVM_target"></a>
<!-- Begin ListElement -->
<!-- motif: Contract -->
<!-- WrappingClass -->
<div class="listRelatedObject Custom18Block"><div class="bPageBlock brandSecondaryBrd secondaryPalette"><div class="pbHeader"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td class="pbTitle"><img class="minWidth" width="1" height="1" title="" alt="" src="/s.gif"></img><img class="relatedListIcon" title="Order" alt="Order" src="/s.gif"></img><h3 id="800f00000006cQt_00Na000000ASdVM_title"> … </h3></td><td class="pbButton"> … </td><td class="pbHelp"> … </td></tr></tbody></table></div><div id="800f00000006cQt_00Na000000ASdVM_body" class="pbBody"> … </div><div class="pbFooter secondaryPalette"> … </div></div></div><div class="listElementBottomNav"></div><script> … </script>
<!-- End ListElement -->
</div>
<!-- End RelatedListElement -->
<!-- Begin RelatedListElement -->
<div id="800f00000006cQt_00Na000000ASdVR" class="bRelatedList"> … </div>
<!-- End RelatedListElement -->
<!-- Begin RelatedListElement -->
<div id="800f00000006cQt_RelatedActivityList" class="bRelatedList"> … </div>
<!-- End RelatedListElement -->
<!-- Begin RelatedListElement -->
<div id="800f00000006cQt_RelatedHistoryList" class="bRelatedList"> … </div>
<!-- End RelatedListElement -->
<!-- Begin RelatedListElement -->
<div id="800f00000006cQt_00Na000000AT3VB" class="bRelatedList"> … </div>
<!-- End RelatedListElement -->
<!-- Begin RelatedListElement -->
<div id="800f00000006cQt_RelatedNoteList" class="bRelatedList"> … </div>
<!-- End RelatedListElement -->
<!-- Begin RelatedListElement -->
<div id="800f00000006cQt_00N3000000A6gu9" class="bRelatedList"> … </div>
<!-- End RelatedListElement -->
<!-- Begin RelatedListElement -->
<div id="800f00000006cQt_RelatedEntityHistoryList" class="bRelatedList"> … </div>
<!-- End RelatedListElement -->
<div class="fewerMore"> … </div><script> … </script>
<!-- Body events -->
<script type="text/javascript"> … </script><div id="datePicker" class="datePicker"> … </div>
<!-- End page content -->
</td></tr></tbody></table></div><div class="bPageFooter noTableFooter"> … </div><div></div></div><script> … </script><script src="/jslibrary/1402506602000/sfdc/ChatterDefer.js" defer="true"></script><script src="/jslibrary/1404472812000/sfdc/Zen.js" defer="true"></script><script> … </script><script async="" defer="" src="/jslibrary/1400606638000/sfdc/SfdcSessionBase190.js"></script><iframe title="sessionserver" style="position: absolute; top: -999px; left: -999px;" src="https://test.salesforce.com/login/sessionserver190.html"></iframe><div id="devSlide" style="display: block;"> … </div><div id="InlineEditDialog" class="overlayDialog cssDialog inlineEditDialog" role="dialog" aria-live="assertive" aria-describedby="InlineEditDialogTitle" style="margin-top: 0px; margin-left: 0px;"> … </div>
When I inspect element in the 1st link it shows table with class=datacell. But there are 2-3 more tables in the page with same class name.
You can use the links method to collect the links and then iterate through the link collection.
Here's a contrived table as an example:
<table class="foo"><tr>
<td>one</td>
<td>two</td>
</tr></table>
<table class="foo"><tr>
<td>three</td>
<td>four</td>
</tr></table>
<table class="bar"><tr>
<td>five</td>
<td>six</td>
</tr></table>
You can collect all the links on the page or target a specific table based on its class attribute or index position.
# print the text attribute for all links
b.links.each { |link| puts link.text}
#=> one
#=> two
#=> three
#=> four
#=> five
#=> six
# print the text attribute for links in the table with a class attribute of "foo"
b.table(:class => "foo").links.each { |link| puts link.text}
#=> one
#=> two
# print the text attribute for links in the table with a index position of 1
b.table(:index => 1).links.each { |link| puts link.text}
#=> three
#=> four
# print the text attribute for links in the table with a class attribute of "bar"
b.table(:class => "bar").links.each { |link| puts link.text}
#=> five
#=> six
In theory--once you've collected the appropriate set of links--you can iterate through the links and click them (although I find this prone to StaleElementReferenceError errors).