Hi I'm trying to scrape 151 Heavy Duty Rubber Gloves - Ex Large from table with following inspect script. Can someone please help with the right Python script?
[<table border="0" class="ProductBox" id="Added0">
<tr>
<td align="center" colspan="2">
<div style="width:100%;float:left;display:inline;float:left;height:37px;"><div style="float:left;font-size:16px;font-family: 'Roboto Condensed', sans-serif;color:white;margin-top:4%;margin-left:6%;"> </div></div>
</td></tr><tr>
<td align="center" colspan="2" height="60px;" valign="top">
<div class="PromoPriceText"> <br/><br/></div><div class="StdPrice">£0.69</div><div class="UnitCost">(£0.69/Unit)</div>
</td>
</tr>
<tr>
<td align="center" colspan="2" height="185">
<a href="/products/DetailsPortal.asp?product_code=104373&Page=Products&BreadPath=/products/gridlist.asp?DeptCode=14*prodgroup=211" style=" line-height: 20px; padding-left: 0px;">
<img alt="" class="effectfront" id="prod" src="/~uldir/104373t.jpg" style="height:165px !important;"/></a>
</td>
</tr>
<tr>
<td class="ProdDetails" style="padding-left:10px;padding-right:10px;margin-bottom:5px;"><input name="product_code" type="hidden" value="104373"/>104373</td>
<td align="right" class="ProdDetails" style="padding-left:10px;padding-right:10px;margin-bottom:5px;">
</td>
</tr>
<tr>
<td class="ProdDetails" colspan="1" style="padding-left:10px;padding-right:10px;margin-bottom:5px;">
POR 0%
</td>
<td align="right" class="ProdDetails" colspan="1" style="padding-left:10px;padding-right:10px;margin-bottom:5px;">
VAT 20%
</td>
</tr>
<tr>
<td class="ProdDetails" colspan="2" style="padding-left:10px;padding-right:10px;margin-bottom:5px;height:50px;">
<a href="/products/DetailsPortal.asp?product_code=104373&Page=Products&BreadPath=/products/gridlist.asp?DeptCode=14*prodgroup=211" style=" line-height: 20px; padding-left: 0px;">
**151 Heavy Duty Rubber Gloves - Ex Large**</a></td>
</tr>
<tr>
<td class="ProdDetails" colspan="1" style="padding-left:10px;padding-right:10px;margin-bottom:5px;">
1s x 1
</td>
<td class="ProdDetails" colspan="1" style="padding-left:10px;padding-right:10px;margin-bottom:5px;float:right;width:98%;text-align:right;">
<div class="tooltip">
<div class="IconWishNS" id="IconWishNS104373" onclick="AddToWish('104373','A')" style="display:inline-block;">
<span class="tooltiptext tooltip-bottom" style="font-size:12px;">Add to Wish List</span></div>
</div>
<span class="OKStatus">In Stock </span>
</td>
</tr>
<tr>
<td colspan="2" style="padding-left:10px;padding-right:10px;margin-bottom:5px;">
<table style="margin-top : 10px;" width="100%">
<tr>
<td>
<img align="middle" alt="Take 1 Off Qty" src="/images/minus.png"/>
</td>
<td>
<input class="iQtyBox" id="104373_qty" maxlength="4" name="104373_qty" oninput="this.value=(parseInt(this.value)||'')" tabindex="1" type="text" value="1"/>
</td>
<td>
<img align="middle" alt="Add 1 To Qty" src="/images/add.png"/>
</td>
<td align="right">
<button class="subBlackButtonDiv subButtonDiv" style="width:70px;margin:0px;" type="button" value="add">Add</button>
</td>
</tr>
</table>
I tied to use the following
r = s.get(url)
soup = BeautifulSoup(r.text, 'lxml')
table = soup.find_all('table')
for i in table:
links = [link.get('href') for link in i.find_all('a')]
print(links)
which unfortunately returns: ['/products/DetailsPortal.asp?product_code=104373&Page=Products&BreadPath=/products/gridlist.asp?DeptCode=14*prodgroup=211', '/products/DetailsPortal.asp?product_code=104373&Page=Products&BreadPath=/products/gridlist.asp?DeptCode=14*prodgroup=211', '#', '#', '#']
Can use the td.ProductDetails a selector (an a tag inside td with the class ProductDetails) to target the text you are interested in, then call .strip() a few times to remove extra characters:
DATA = """<table border="0" class="ProductBox" id="Added0">
<tr>
...
</table>"""
from bs4 import BeautifulSoup
from typing import Optional
def extract_name(data: str) -> Optional[str]:
soup = BeautifulSoup(data, "html.parser")
links = soup.select("td.ProdDetails a")
if len(links) >= 1:
return links[0].text.strip().strip("*").strip()
else:
return None
print(extract_name(DATA))
# like above
r = s.get(url)
soup = BeautifulSoup(r.text, 'lxml')
tables = soup.find_all('table')
text = extract_name(tables[0])
Output: 151 Heavy Duty Rubber Gloves - Ex Large
I have this HTML code for example:
<table class="nested4">
<tr>
<td colspan="1"></td>
<td colspan="2">
<h2 class="zeroMargin" id="govtMsg" visible="false"></h2>
</td>
<td colspan="2">
<h2 class="zeroMargin "> Net Metering Conn. </h2>
</td>
<td colspan="2">
<h2 class="zeroMargin" hidden> Life Line Consumer</h2>
</td>
</tr>
<tr>
<td colspan="2">
<p style="margin: 0; text-align: left; padding-left: 5px">
<span>NAME & ADDRESS</span>
<br />
<span>MUHAMMAD AMIN </span>
<br />
<span>S/O MUHAMMAD KHAN </span>
<br />
<span>H-NO.38 MARGALLA ROAD </span>
<br />
<span>F-6/3 ISLAMABAD3 </span>
<br />
<span></span>
</p>
</td>
<td colspan="3" style="text-align: left">
<h2 class="color-red">Say No To Corruption</h2>
<span style="font-size: 8pt; color: #78578e"> MCO Date : 10-Aug-2018</span>
<br />
</td>
<td>
<h3 style="font-size: 14pt;"> </h3>
<h2> <br /> </h2>
</td>
</tr>
<tr>
<td style="margin-top: 0;" class="border-b">
<br />
</td>
<td colspan="1" style="margin-top: 0;" class="border-b">
</td>
<td colspan="1" style="margin-top: 0;" class="border-b">
</td>
</tr>
<tr style="height: 7%;" class="border-tb">
<td style="width: 130px" class="border-r">
<h4>METER NO</h4>
</td>
<td style="width: 90px" class="border-r">
<h4>PREVIOUS READING</h4>
</td>
<td style="width: 90px" class="border-r">
<h4>PRESENT READING</h4>
</td>
<td style="width: 60px" class="border-r">
<h4>MF</h4>
</td>
<td style="width: 60px" class="border-r">
<h4>UNITS</h4>
</td>
<td>
<h4>STATUS</h4>
</td>
</tr>
<tr style="height: 30px" class="content">
<td class="border-r">
3-P I 3301539<br> I 3301539<br> E 3301539<br> E 3301539<br>
</td>
<td class="border-r">
78693<br>16823<br>19740<br>8<br>
</td>
<td class="border-r">
80086<br>17210<br>20139<br>8<br>
</td>
<td class="border-r">
1<br>1<br>1<br>1<br>
</td>
<td class="border-r">
1393<br>387<br>399<br>0<br>
</td>
<td>
</td>
</tr>
<tr id="roshniMsg" style="height: 30px" class="content">
<td colspan="6">
<div style="width: 452pt">
<img style="max-width: 100%; max-height: 35%" src="/images/companies/iesco/roshniMsg.jpg"
alt="Roshni Message" />
</div>
</td>
</tr>
</table>
From this table I want to extract the paragraph and from there I want to get all the span tags in that paragraph.
I used soup.find_all() to get the table but I don't know how to use this function iteratively to pass it back to the original soup object so that I could find the paragraph and, moreover the span tags in that paragraph.
This is the code Python code I wrote:
soup = BeautifulSoup(string, 'html.parser')
#Getting the table tag
results = soup.find_all('table', attrs={'class':'nested4'})
#Getting the paragragh tag
results = soup.find_all('p', attrs={'style':'margin: 0; text-align: left; padding-left: 5px'})
#Getting all the span tags
results = soup.find_all('span', attrs={})
I just want help on how to get the paragraphs within the table. And then how to get the spans within the paragraph as I am getting the spans in all of the original HTML code. I don't know how to pass the bs4 object list back to the soup object to use soup.find_all iteratively.
from bs4 import BeautifulSoup
html = '''
<table class="nested4">
<tr>
<td colspan="1"></td>
<td colspan="2">
<h2 class="zeroMargin" id="govtMsg" visible="false"></h2>
</td>
<td colspan="2">
<h2 class="zeroMargin "> Net Metering Conn. </h2>
</td>
<td colspan="2">
<h2 class="zeroMargin" hidden> Life Line Consumer</h2>
</td>
</tr>
<tr>
<td colspan="2">
<p style="margin: 0; text-align: left; padding-left: 5px">
<span>NAME & ADDRESS</span>
<br />
<span>MUHAMMAD AMIN </span>
<br />
<span>S/O MUHAMMAD KHAN </span>
<br />
<span>H-NO.38 MARGALLA ROAD </span>
<br />
<span>F-6/3 ISLAMABAD3 </span>
<br />
<span></span>
</p>
</td>
<td colspan="3" style="text-align: left">
<h2 class="color-red">Say No To Corruption</h2>
'''
soup = BeautifulSoup(html, 'html.parser')
spans = soup.select_one('table.nested4').select('span')
for span in spans:
print(span.text)
This returns:
NAME & ADDRESS
MUHAMMAD AMIN
S/O MUHAMMAD KHAN
H-NO.38 MARGALLA ROAD
F-6/3 ISLAMABAD3
if you have one table:
soup = BeautifulSoup(string, 'html.parser')
table = soup.find('table', attrs={'class': 'nested4'})
p = table.find('p', attrs={'style': 'margin: 0; text-align: left; padding-left: 5px'})
results = p.find_all('span')
for result in results:
print(result.get_text(strip=True))
if you have list of tables:
soup = BeautifulSoup(string, 'html.parser')
for table in soup.find_all('table', attrs={'class': 'nested4'}):
for p in table.find_all('p', attrs={'style': 'margin: 0; text-align: left; padding-left: 5px'}):
for span in p.find_all('span'):
print(span.get_text(strip=True))
I'm trying to extract data from a table that lies in between two headers in an html file using Python. IN this case, the required id to lookup lies in a span inside a header (I need id="Perlis", which lies between Perlis and Kedah):
<h2>
<span class="mw-headline" id="Perlis">Perlis</span>
<span class="mw-editsection">
<span class="mw-editsection-bracket">[</span>
edit
<span class="mw-editsection-bracket">]</span>
</span>
</h2>
<table class="wikitable" style="text-align:center; font-size:90%; width:100%;">
<tbody>
<tr>
<th width="30"># </th>
<th width="150">Constituency s </th>
<th width="150">Winner </th>
<th width="80">Votes </th>
<th width="80">Majority </th>
<th width="150">Opponent(s) </th>
<th width="80">Votes </th>
<th width="150">Incumbent </th>
<th width="80">
<b>Incumbent Majority</b>
</th>
</tr>
<tr>
<td colspan="13">
BN
<b>2</b> | GS
<b>0</b> | PH
<b>1</b> | Independent
<b>0</b>
</td>
</tr>
<tr align="center">
<td rowspan="2">P1 </td>
<td rowspan="2">
Padang Besar
</td>
<td rowspan="2" bgcolor="#B5BED9">
Zahidi Zainul Abidin
<br /> ( <b>BN</b>- <b>UMNO</b>)
</td>
<td rowspan="2">
<b>15,032</b>
</td>
<td rowspan="2">
<b>1,438</b>
</td>
<td bgcolor="#F18A8F">Izizam Ibrahim <br /> ( <b>PH</b>- <b>PPBM</b>) </td>
<td>
<b>13,594</b>
</td>
<td rowspan="2" bgcolor="#B5BED9">
Zahidi Zainul Abidin
<br /> ( <b>BN</b>- <b>UMNO</b>)
</td>
<td rowspan="2">
<b>7,426</b>
</td>
</tr>
<tr>
<td bgcolor="#B2DBB2">Mokhtar Senik <br /> ( <b>GS</b>- <b>PAS</b>) </td>
<td>
<b>7,874</b>
</td>
</tr>
<tr align="center">
<td rowspan="2">P2 </td>
<td rowspan="2">
Kangar
</td>
<td rowspan="2" bgcolor="#C7F2F2">Noor Amin Ahmad <br /> ( <b>PH</b>- <b>PKR</b>) </td>
<td rowspan="2">
<b>20,909</b>
</td>
<td rowspan="2">
<b>5,603</b>
</td>
<td bgcolor="#B5BED9">Ramli Shariff <br /> ( <b>BN</b>- <b>UMNO</b>) </td>
<td>
<b>15,306</b>
</td>
<td rowspan="2" bgcolor="#B5BED9">
Shaharuddin Ismail
<br /> ( <b>BN</b>- <b>UMNO</b>)
</td>
<td rowspan="2">
<b>4,037</b>
</td>
</tr>
<tr>
<td bgcolor="#B2DBB2">Mohamad Zahid Ibrahim <br /> ( <b>GS</b>- <b>PAS</b>) </td>
<td>
<b>8,465</b>
</td>
</tr>
</tbody>
</table>
<h2>
<span class="mw-headline" id="Kedah">Kedah</span>
<span class="mw-editsection">
<span class="mw-editsection-bracket">[</span>
edit
<span class="mw-editsection-bracket">]</span>
</span>
</h2>
<table class="wikitable" style="text-align:center; font-size:90%; width:100%;"></table>
This is the resulting JSON that I am trying to construct:
[
{
"state": "Perlis",
"constituencies": [
{
"id": "P1",
"name": "Padang Besar"
},
{
"id": "P2",
"name": "Kangar"
}
]
}
]
I'd like to know how to reference the specific table so I can extract the data into a JSON format. I have used Scrapy before but not sure how to in this case- this is what I had in mind:
class PostSpider(scrapy.Spider):
name = 'manual_spider'
start_urls = [
'%URL%'
]
def parse(self, response):
doc = response.xpath('//comment()').getall() //This is the bit I need
//code continues here
I´m getting the following error on python when I trying to do some scraping:
Traceback (most recent call last):
File "", line 26, in
signin2.fields["ctl06$txtParam_1"].value = '139210'
File "C:\Users\Alvaro
Pabon\Anaconda3\lib\site-packages\werkzeug\datastructures.py", line
781, in getitem
raise exceptions.BadRequestKeyError(key)
BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a
request that this server could not understand.
I provide the html and the python code, what am I doing wrong?
HTML:
<form method="post" action="Default.aspx?IdControl=SolicitarReporteUC&TipoProceso=G" id="Form1">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTE2MjczMjc4MQ9kFgICAw9kFgICBQ9kFgJmD2QWDgIBDxAPFgYeDkRhdGFWYWx1ZUZpZWxkBQpDb2RSZXBvcnRlHg1EYXRhVGV4dEZpZWxkBQdSZXBvcnRlHgtfIURhdGFCb3VuZGdkEBUBI0NlcnRpZmljYWRvIGRlIGhpc3RvcmlhIGxhYm9yYWwgRlBNFQEFMTAwOTUUKwMBZxYBZmQCAw9kFgJmD2QWAgIBD2QWAgIBDw9kFgIeB29uY2xpY2sFdmphdmFzY3JpcHQ6cmV0dXJuIEJ1c2NhckNvblBvc3RCYWNrKCdFbXBsZWFkb19WSVBQJywnQ29kRW1wbGVhZG8nLCdFbXBsZWFkbycsJycsJ2N0bDA2X3R4dFBhcmFtXzEnLCdjdGwwNl90eHREZXNjXzEnKTtkAgcPDxYCHgRUZXh0ZWRkAgkPEA8WAh4HVmlzaWJsZWdkEBUBA1BERhUBA1BERhQrAwFnZGQCCw8PFgIeB0VuYWJsZWRnZGQCDQ8PFgIfBGVkZAIRDzwrAAsBAA8WCB4IRGF0YUtleXMWAB4LXyFJdGVtQ291bnQCAR4JUGFnZUNvdW50AgEeFV8hRGF0YVNvdXJjZUl0ZW1Db3VudAIBZBYCZg9kFgICAg9kFgxmD2QWAgIDDw8WAh4LTmF2aWdhdGVVcmwFOkRlZmF1bHQuYXNweD9JZENvbnRyb2w9UGV0aWNpb25lc1ZlclVDJkNvZFBldGljaW9uPTk4NDI0NjZkZAIBDw8WAh8EBQc5ODQyNDY2ZGQCAg8PFgIfBAUKMDQvMDcvMjAxN2RkAgMPDxYCHwQFLENlcnRpZmljYWRvIGRlIGhpc3RvcmlhIGxhYm9yYWwgRlBNKDEzOTIxMCwpZGQCBA8PFgIfBAUBVGRkAgUPDxYCHwQFCVRlcm1pbmFkb2RkZG9xWba643oqthJTATkgc95Acvr6oJVDDdMGc4QiUOHQ" />
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['Form1'];
if (!theForm) {
theForm = document.Form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<script src="/peoploEL/WebResource.axd?d=Vo5dwRm0erdgUaaz932BKtVNZGJOgXKXcR91FZwwFfehyhj6Sl2EkKnl2mAONakSWUxeINyfjibWOjKY8z8OLswtutIQ6CR4NPqhOOhW3-c1&t=635195493660000000" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var __cultureInfo = {"name":"es-CO","numberFormat":{"CurrencyDecimalDigits":2,"CurrencyDecimalSeparator":",","IsReadOnly":true,"CurrencyGroupSizes":[3],"NumberGroupSizes":[3],"PercentGroupSizes":[3],"CurrencyGroupSeparator":".","CurrencySymbol":"$","NaNSymbol":"NeuN","CurrencyNegativePattern":14,"NumberNegativePattern":1,"PercentPositivePattern":0,"PercentNegativePattern":0,"NegativeInfinitySymbol":"-Infinito","NegativeSign":"-","NumberDecimalDigits":2,"NumberDecimalSeparator":",","NumberGroupSeparator":".","CurrencyPositivePattern":2,"PositiveInfinitySymbol":"Infinito","PositiveSign":"+","PercentDecimalDigits":2,"PercentDecimalSeparator":",","PercentGroupSeparator":".","PercentSymbol":"%","PerMilleSymbol":"‰","NativeDigits":["0","1","2","3","4","5","6","7","8","9"],"DigitSubstitution":1},"dateTimeFormat":{"AMDesignator":"a.m.","Calendar":{"MinSupportedDateTime":"\/Date(-62135578800000)\/","MaxSupportedDateTime":"\/Date(253402300799999)\/","AlgorithmType":1,"CalendarType":1,"Eras":[1],"TwoDigitYearMax":2029,"IsReadOnly":true},"DateSeparator":"/","FirstDayOfWeek":0,"CalendarWeekRule":0,"FullDateTimePattern":"dddd, dd\u0027 de \u0027MMMM\u0027 de \u0027yyyy hh:mm:ss tt","LongDatePattern":"dddd, dd\u0027 de \u0027MMMM\u0027 de \u0027yyyy","LongTimePattern":"hh:mm:ss tt","MonthDayPattern":"dd MMMM","PMDesignator":"p.m.","RFC1123Pattern":"ddd, dd MMM yyyy HH\u0027:\u0027mm\u0027:\u0027ss \u0027GMT\u0027","ShortDatePattern":"dd/MM/yyyy","ShortTimePattern":"hh:mm tt","SortableDateTimePattern":"yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027T\u0027HH\u0027:\u0027mm\u0027:\u0027ss","TimeSeparator":":","UniversalSortableDateTimePattern":"yyyy\u0027-\u0027MM\u0027-\u0027dd HH\u0027:\u0027mm\u0027:\u0027ss\u0027Z\u0027","YearMonthPattern":"MMMM\u0027 de \u0027yyyy","AbbreviatedDayNames":["dom","lun","mar","mié","jue","vie","sáb"],"ShortestDayNames":["do","lu","ma","mi","ju","vi","sá"],"DayNames":["domingo","lunes","martes","miércoles","jueves","viernes","sábado"],"AbbreviatedMonthNames":["ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic",""],"MonthNames":["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre",""],"IsReadOnly":true,"NativeCalendarName":"calendario gregoriano","AbbreviatedMonthGenitiveNames":["ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic",""],"MonthGenitiveNames":["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre",""]},"eras":[1,"d.C.",null,0]};//]]>
</script>
<script src="/peoploEL/ScriptResource.axd?d=oxaJQOalmF_Pc9FHyAFTk_k6TF1NEbUrjIYsB44pk6WCbYo_nSIw4yk5tC2xEtvEorNRA5gOfFsIU4ZnWzjKxobYxQm7qlMyDI-yMbMSd2l6ZDbJap8N8TY6mfiS7PCqS0ZD_N1nysIMDoEuJENdCQ2&t=23c9c237" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>
</script>
<div class="aspNetHidden">
<input type="hidden" name="__SCROLLPOSITIONX" id="__SCROLLPOSITIONX" value="0" />
<input type="hidden" name="__SCROLLPOSITIONY" id="__SCROLLPOSITIONY" value="0" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAArkW6hVSYy1X/RA+Sj0CGQLGp+bdMCDYaJlV2GIWm9IvBdcfX0kLMsTvDhzcFP+5BCmu+5iWjvwd5K06ry8EbPN8eAu30BFMFNpn4fF9w5RD0sfx0Rt1Zoo22r6RgHWIEvbk+/Q0viP1b4fioHhV6vuLByhWnJD/fsZOTyD54nbDa+qASD48033XmTIh5CNr4axLA/MabVFryGhaiI+QVUeJtZhbNAXh60wJUXNyENePpp0PUjhju74p8tImEJGpMk=" />
</div>
<TABLE id="Table1" border="0" cellSpacing="0" cellPadding="0" width="80%" align="center"
height="72%">
<TR>
<TD height="25" vAlign="top" width="165" align="center"></TD>
<TD height="25" width="10"></TD>
<TD height="25" vAlign="top"></TD>
</TR>
<TR>
<TD vAlign="top" width="165" align="center">
<LINK rel="stylesheet" type="text/css" href="EstilosWeb.css">
<LINK rel="stylesheet" type="text/css" href="EstilosWeb.css">
<TABLE style="WIDTH: 160px; HEIGHT: 64px" id="tMain" class="main" cellPadding="0" width="160">
<TR vAlign="top">
<TD id="NavTd">
<DIV id="Nav">
<H4 align="center">Menu
<table id="PanelIzquierdoUC1_htbCategorias" cellspacing="0" cellpadding="0" style="border-width:0px;width:160px;border-collapse:collapse;">
<tr>
<td><a id="PanelIzquierdoUC1_ConsultarLiquidacion" title="Consulta de Liquidación" href="Default.aspx?IdControl=ConsultaLiquidacionFltUC">Consultar Liquidación</a></td>
</tr><tr>
<td><a id="PanelIzquierdoUC1_Reportes" title="Certificado Ing. y Ret." href="Default.aspx?IdControl=ReportesUC">Certificado Ing. y Ret.</a></td>
</tr><tr>
<td><a id="PanelIzquierdoUC1_CambiarClave" title="Cambio de Clave" href="Default.aspx?IdControl=CambioClaveUC">Cambio de Clave</a></td>
</tr><tr>
<td><a id="PanelIzquierdoUC1_ReportesGeneral" title="Reportes" href="Default.aspx?IdControl=SolicitarReporteUC&TipoProceso=G">Reportes</a></td>
</tr><tr>
<td><a id="PanelIzquierdoUC1_CerrarSesion" title="Cerrar Sesion" href="Default.aspx?IdControl=CerrarSesionUC">Cerrar Sesion</a></td>
</tr>
</table></H4>
</DIV>
</TD>
</TR>
</TABLE>
</TD>
<td width="10"> </td>
<TD vAlign="top">
<div id="pnlCargaUserControl" style="width:100%;">
<LINK href="EstilosWeb.css" type="text/css" rel="stylesheet">
<style type="text/css">
.style1
{
height: 26px;
width: 36px;
}
</style>
<TABLE class="FormaTabla" id="Table1" cellSpacing="1" cellPadding="1" width="300" border="0">
<TR>
<TD class="FormaEncabezado" colSpan="2">Reportes</TD>
</TR>
<TR>
<TD colSpan="2">
<P align="center"> </P>
</TD>
</TR>
<TR>
<TD colSpan="2"><select size="4" name="ctl06$lstReportes" onchange="javascript:setTimeout('__doPostBack(\'ctl06$lstReportes\',\'\')', 0)" id="ctl06_lstReportes" class="FormaInfo" style="height:215px;width:564px;">
<option selected="selected" value="10095">Certificado de historia laboral FPM</option>
</select></TD>
</TR>
<TR>
<TD colSpan="2">Parametros</TD>
</TR>
<TR>
<TD style="HEIGHT: 45px" colSpan="2"><table id="ctl06_tbParametros" rules="all" border="1">
<tr>
<td>Empleado</td><td><input name="ctl06$txtParam_1" type="text" value="139211" readonly="readonly" onchange="javascript:setTimeout('__doPostBack(\'ctl06$txtParam_1\',\'\')', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="ctl06_txtParam_1" Tabla="Empleado_VIPP" CodigoCampo="CodEmpleado" DescripcionCampo="Empleado" Condicion="" TipoDato="N" Parametro="Empleado" /><input type="submit" name="ctl06$btnParam_1" value="..." id="ctl06_btnParam_1" disabled="disabled" class="aspNetDisabled" onclick="javascript:return BuscarConPostBack('Empleado_VIPP','CodEmpleado','Empleado','','ctl06_txtParam_1','ctl06_txtDesc_1');" style="width:25px;" /></td><td><input name="ctl06$txtDesc_1" type="text" value="JUAN DE LOS PALOTES" readonly="readonly" id="ctl06_txtDesc_1" style="width:250px;" /></td>
</tr>
</table></TD>
</TR>
<TR>
<TD class="style1">
</TD>
<td>
<P align="center"><select name="ctl06$ddlFormato" id="ctl06_ddlFormato" style="width:104px;">
<option value="PDF">PDF</option>
</select> <input type="submit" name="ctl06$btnAceptar" value="Aceptar" id="ctl06_btnAceptar" />
</P>
</td>
</TR>
<TR>
<TD colSpan="2">
<P align="left"><span id="ctl06_lblMensaje" style="color:Red;font-family:Arial;"></span></P>
</TD>
</TR>
</TABLE>
<P>
<input type="submit" name="ctl06$ButActualizar" value="Actualizar" id="ctl06_ButActualizar" /></P>
<P><table class="FormaGrid" cellspacing="0" rules="all" border="1" id="ctl06_dtgDatos" style="border-collapse:collapse;">
<tr>
<td> </td><td>CodPeticion</td><td>FechaHora</td><td>Peticion</td><td>Estado</td><td>DetalleEstado</td>
</tr><tr>
<td style="white-space:nowrap;">
<a id="ctl06_dtgDatos_ctl03_cmdVer" href="javascript:__doPostBack('ctl06$dtgDatos$ctl03$cmdVer','')">Ver</a>
</td><td>9842466</td><td>04/07/2017</td><td>Certificado(139211,)</td><td>T</td><td>Terminado</td>
</tr><tr>
<td colspan="6"><span>1</span></td>
</tr>
</table></P>
</div>
</TD>
</TR>
</TABLE>
PYTHON:
form2 = browser.get_form(id='Form1')
form2["ctl06$txtParam_1"].value = '139211'
form2["ctl06$txtDesc_1"].value = 'JUAN DE LOS POTES'
form2["ctl06$ddlFormato"].value = 'PDF'
form2["ctl06$lstReportes"].value = '10095'
form2["__EVENTTARGET"].value = 'ctl06$dtgDatos$ctl03$cmdVer'
form2["__EVENTARGUMENT"].value = ''
browser.submit_form(signin2)
Use python request lib for that
Create Json and pass it through the headers and remember <__EVENTTARGET>
<__EVENTARGUMENT> This previous <> mention parameter always changing after few minute (based on website).
It Will easy if you use POST method and for before sending request check it in POSTMAN once.
header = {
"ctl00$ContentPlaceHolder1$txt_tradename": str(index),
"ctl00$ContentPlaceHolder1$txtSearchTin": "",
"ctl00$ContentPlaceHolder1$ddl_dist": 2,
"ctl00$ContentPlaceHolder1$btnDlrSearch": "Search",
"__EVENTVALIDATION": token.get("__EVENTVALIDATION", "")
, "__VIEWSTATEGENERATOR": token.get("__VIEWSTATEGENERATOR"),
"__VIEWSTATE": token.get("__VIEWSTATE")
}
try:
req = requests.post(url, header)
How could I click the link highlighted in the attached image using python selenium library, i have tried everything (most attempts shown below), but all not working.
note in the attached picture the element tree.
Page code (link in question is the last link in the code below:
<HEAD>
<TITLE> Constructor Self Service</TITLE>
</HEAD>
<script type="text/javascript">
......
</script>
<link rel="stylesheet"
href="/global/res/themes/corporate/css/style3.css"
type="text/css">
<script type="text/javascript"
src="/global/res/javascript/horizontal_subsection_HM_Loader.js"></script>
<link rel=stylesheet href="css/tcss.css" TYPE="text/css">
<script type="text/javascript" src="arrays/aaclib.js"></script>
<script type="text/javascript" src="arrays/csslib.js"></script>
<table cellspacing=0 cellpadding=0 border=0 width="100%" height="100%" >
<tr><td valign="top">
<form name="mainForm" action="/TCSSPRODapp/Controller"
method="POST" onsubmit="return false;">
<input type="hidden" name="command">
<input type="hidden" name="page">
<input type="hidden" name="menuIndex">
<input type="hidden" name="submitted" value="false">
<input type="hidden" name="pageToken"
value=679>
<input type="hidden" name="isInternal"
value=false>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0">
<!--begin global header--><!--Don't place any other HTML code on this line!!-->
<script language="javascript" src="/global/javascript/head_array.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
var v6=0;
if(typeof hmVisi!="undefined"&&typeof sectionId!="undefined" )v6=1;
if(v6)document.write('</head><body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="TEL_onLoad()">');
function alertUser() {
if(confirm("Warning: Any unsaved data would be lost.\rDo you want to Continue?")) {
return true;
} else {
return false;
}
}
</script>
<link rel="stylesheet" href="/global/css/gwy_hed.css" type="text/css">
<a name="top"></a>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td rowspan="4" valign="top"><img src="/global/images/telstra_logo2.gif" width="85" height="85" border="0" alt="telstra.com"></td>
<td align="right" class="ap1"><span class="hd1"><img src="/global/images/sin.gif" width="1" height="37" border="0" alt="press enter now to toggle the accessibile text mode of this page" align="absmiddle">
Telstra Homepage | Contact Us | Search<img src="/global/images/sin.gif" width="12" height="1" alt=""></span></td>
<td width="50%" class="ap1"><img src="/global/images/sin.gif" width="1" height="57" alt=""></td>
</tr>
<tr class="hd3">
<!--<td><img src="/global/images/sin.gif" width="500" height="2" alt=""></td>-->
<td colspan=50 width="100%"><img src="/global/images/sin.gif" width="100" height="2" alt=""></td>
<td><img src="/global/images/sin.gif" width="1" height="2" alt=""></td>
</tr>
<tr>
<td align="right"><img src="/global/images/gwy_grad.gif" width="328" height="6" alt=""></td>
<td class="hd4"><img src="/global/images/sin.gif" width="1" height="1" alt=""></td>
</tr>
<tr>
<td colspan=2 class="hd5" nowrap><NOBR>
<table cellpadding=1 cellspacing=1 border=0>
<tr>
<!-- AMCO-WORKFLOW:MODIFY:START -->
<!--<td rowspan=3 class="hd5" nowrap><img src="/global/images/sin.gif" width="15" height="10" alt="" align="top">Telstra Contractor Self Service<img src="/global/images/sin.gif" width="25" height="1" alt="" align="top"></td>-->
<td rowspan=4 class="hd5" nowrap><img src="/global/images/sin.gif" width="5" height="10" alt="" align="top">Telstra Constructor Self Service<img src="/global/images/sin.gif" width="5" height="1" alt="" align="top"></td>
<!-- AMCO-WORKFLOW:MODIFY:END -->
<TD nowrap><img src="/global/images/sin.gif" width="10" height="12"></TD>
<TD nowrap></TD>
<TD nowrap></TD>
<!-- AMCO-WORKFLOW:ADD:START -->
<!--5.14.01 Anand Changes: start-->
<!--<TD nowrap></TD>-->
<!--5.14.01 Anand Changes: start-->
<!-- AMCO-WORKFLOW:ADD:END -->
<!--5.14.01 Anand Changes: start-->
</tr>
<tr style="background-color:#99ccff;">
<!-- AMCO-WORKFLOW:ADD:START -->
<TD class=button>
<a class=button style="text-decoration:none"
title="AMCO"
href="javascript:doCommand('doWidebandWorkSummary')"
onmousemove="window.status='View Work Summary'"
onmouseout="window.status=window.defaultStatus">
AMCO</a>
</TD>
<!-- AMCO-WORKFLOW:ADD:END -->
<TD nowrap style="background-color:#ffffff;"></TD>
<TD class=button nowrap>
<a class=button style="text-decoration:none"
title="View Inbox"
href="javascript:doCommand('doInboxStat')"
onmousemove="window.status='View Inbox'"
onmouseout="window.status=window.defaultStatus">
<NOBR>Inbox 0</NOBR></a>
</TD>
<TD class=button>
<a class=button style="text-decoration:none"
title="View Outbox"
href="javascript:doCommand('doOutboxStat')"
onmousemove="window.status='View Outbox'"
onmouseout="window.status=window.defaultStatus">
<NOBR>Outbox 0</NOBR></a>
</TD>
<!--Start : IPaC Stage II Drop1 : Refresh button added-->
<TD class=button>
<a class=button style="text-decoration:none"
title="Refresh Inbox and Outbox"
href="javascript:doCommand('doInboxOutboxRefresh')"
onmousemove="window.status='Refresh Inbox and Outbox'"
onmouseout="window.status=window.defaultStatus"
onclick="return alertUser()">
<NOBR>Refresh</NOBR></a>
</TD>
<!--End : IPaC Stage II Drop1-->
<TD nowrap style="background-color:#ffffff;"></TD>
<TD class=button nowrap>
<a class=button style="text-decoration:none"
title="Display TCSS help"
href="javascript:loadHelpWindow()"
onmousemove="window.status='Display TCSS help'"
onmouseout="window.status=window.defaultStatus">
<NOBR>Help</NOBR></a>
</TD>
<!-- AMCO-WORKFLOW:ADD:START -->
<!--5.14.01 Anand Changes: start-->
<!--<TD nowrap width="151" style="background-color:#ffffff;"></TD>-->
<!--5.14.01 Anand Changes: end-->
</tr>
<tr>
<TD nowrap><img src="/global/images/sin.gif" width="38" height="12"></TD>
<!--Start : IPaC Stage II Drop1 : Display message if refresh didnt occur-->
<TD nowrap style="background-color:#ffffff;"></TD>
<TD nowrap><img src="/global/images/sin.gif" width="38" height="12"></TD>
<TD nowrap style="background-color:#ffffff;"></TD></tr>
<tr>
<TD nowrap><img src="/global/images/sin.gif" width="38" height="12"></TD>
<TD nowrap style="background-color:#ffffff;"></TD>
</tr>
<!--<TD nowrap></TD>-->
<!--<TD nowrap></TD>-->
<!-- AMCO-WORKFLOW:ADD:START -->
<!--<TD nowrap></TD>-->
<!-- AMCO-WORKFLOW:ADD:END -->
<!--End : IPaC Stage II Drop1-->
</tr>
</table>
</NOBR>
</td>
</tr>
</table>
<script language="javascript" type="text/javascript">
<!--5.14.01 Anand Changes: changed from 100% to 15 % start-->
var s='<table width="50%" cellpadding="0" cellspacing="0" border="0"><tr><td class="siteletTitleTab"><img src="/global/images/sin.gif" width="1" height="3" alt=""></td></tr></table>';
<!--5.14.01 Anand Changes: changed from 100% to 15 % end-->
if(v6)document.write(s);
</script>
<!--end global header--><!--Don't place any other HTML code on this line!!-->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="">
<td width="100%" rowspan="2" align=right>
</td>
<TD>
<INPUT type="hidden" name="internalConstructor" size=10 value="false"> </TD>
</tr>
</table>
<table border=0 cellspacing=0 cellpadding=0 width=100%>
<tr><td colspan=50 class=sitelettitletab>
<img src=/global/res/images/sin.gif width=0 height=3>
</td></tr><tr class=sitelettitletab>
<td><img src=/global/res/images/sin.gif width=3 height=1></td><td class=sitetabnav valign=top><img src=/global/res/themes/corporate/images/tab_left_inactive.gif width=8 height=20></td><td class=sitetabnav valign=middle align=center nowrap><a class=sitetabnav href='javascript:doCommand("doFrontPage")' onmousemove="window.status='Home Page'" onmouseout="window.status=window.defaultStatus" title='Home Page'>Home Page</a></td><td align=right class=sitetabnav valign=top><img src=/global/res/themes/corporate/images/tab_right_inactive.gif width=8 height=20>
<td><img src=/global/res/images/sin.gif width=3 height=1></td><td class=sitetabnav valign=top><img src=/global/res/themes/corporate/images/tab_left_inactive.gif width=8 height=20></td><td class=sitetabnav valign=middle align=center nowrap><a class=sitetabnav href='javascript:doCommand("doTransmittalsInbox")' onmousemove="window.status='My TCSS'" onmouseout="window.status=window.defaultStatus" title='My TCSS'>My TCSS</a></td><td align=right class=sitetabnav valign=top><img src=/global/res/themes/corporate/images/tab_right_inactive.gif width=8 height=20>
<td><img src=/global/res/images/sin.gif width=3 height=1></td><td class=siteactivetabnav valign=top><img src=/global/res/themes/corporate/images/tab_left_inactive.gif width=8 height=20></td><td class=siteactivetabnav valign=top><img src=/global/res/images/sin.gif width=5 height=20></td><td class=siteactivetabnav valign=middle align=center nowrap><img src=/global/res/themes/corporate/images/tick.gif width=8 height=9> <a class=siteactivetabnav onmousemove="window.status='Work Under Contract'" onmouseout="window.status=window.defaultStatus">Work Under Contract</a></td><td align=right class=siteactivetabnav valign=top><img src=/global/res/themes/corporate/images/tab_right_inactive.gif width=8 height=20></td>
<td><img src=/global/res/images/sin.gif width=3 height=1></td><td class=sitetabnav valign=top><img src=/global/res/themes/corporate/images/tab_left_inactive.gif width=8 height=20></td><td class=sitetabnav valign=middle align=center nowrap><a class=sitetabnav href='javascript:doCommand("doGenDocSearch")' onmousemove="window.status='Documents'" onmouseout="window.status=window.defaultStatus" title='Documents'>Documents</a></td><td align=right class=sitetabnav valign=top><img src=/global/res/themes/corporate/images/tab_right_inactive.gif width=8 height=20>
<td><img src=/global/res/images/sin.gif width=3 height=1></td><td class=sitetabnav valign=top><img src=/global/res/themes/corporate/images/tab_left_inactive.gif width=8 height=20></td><td class=sitetabnav valign=middle align=center nowrap><a class=sitetabnav href='javascript:doCommand("doAssetSearch")' onmousemove="window.status='Reference Library'" onmouseout="window.status=window.defaultStatus" title='Reference Library'>Reference Library</a></td><td align=right class=sitetabnav valign=top><img src=/global/res/themes/corporate/images/tab_right_inactive.gif width=8 height=20>
<td><img src=/global/res/images/sin.gif width=3 height=1></td><td class=sitetabnav valign=top><img src=/global/res/themes/corporate/images/tab_left_inactive.gif width=8 height=20></td><td class=sitetabnav valign=middle align=center nowrap><a class=sitetabnav href='javascript:doCommand("doAbout")' onmousemove="window.status='Support'" onmouseout="window.status=window.defaultStatus" title='Support'>Support</a></td><td align=right class=sitetabnav valign=top><img src=/global/res/themes/corporate/images/tab_right_inactive.gif width=8 height=20>
<td><img src=/global/res/images/sin.gif width=3 height=1></td><td class=sitetabnav valign=top><img src=/global/res/themes/corporate/images/tab_left_inactive.gif width=8 height=20></td><td class=sitetabnav valign=middle align=center nowrap><a class=sitetabnav href='javascript:doLogout()' onmousemove="window.status='Close TCSS'" onmouseout="window.status=window.defaultStatus" title='Close TCSS'>Close TCSS</a></td><td align=right class=sitetabnav valign=top><img src=/global/res/themes/corporate/images/tab_right_inactive.gif width=8 height=20>
<td width=100%><img src=/global/res/images/sin.gif width=1 height=1></td></tr><tr><td colspan=50><img src=/global/res/images/sin.gif width=0 height=2></td></tr></table>
<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td>
<img src='/global/res/images/sin.gif' width=1 height=3></td></tr><tr class=sitetabnav><td>
<table cellpadding=0 cellspacing=0 border=0><tr><script type='text/javascript'>
TEL_horizontalSubsectionNav('corporate')
</script><td width=100%> </td></tr></table></td></tr></table>
<table cellspacing=10 cellpadding=0 border=0 width="100%">
<tr><td valign=top width="100%">
<TABLE border=0 cellpadding=0 cellspacing=0 width=100%>
<TR><TD bgcolor=#99ccff>
<TABLE cellspacing=2 cellpadding=0 border=0 width=100%>
<TR><TD bgcolor=#F1F8FE>
<TABLE border=0 cellpadding=0 cellspacing=0>
<TR><TD colspan=2 height=1 bgcolor=#F1F8FE></TD>
<TD rowspan=3><IMG border=0 src='images/corner.jpg'></TD>
</TR><TR><TD><IMG border=0 width=1 height=1 src='images/whitedot.gif'></TD>
<TD class='groupboxheader'> WUC CSA - Scope Variation - Site & Financial Details </TD></TR></TABLE>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" WIDTH="100%">
<TR>
<TD CLASS="label" WIDTH="20%">Contract Number:</TD>
<TD WIDTH="25%" CLASS="fieldlabel">20003171</TD>
<TD CLASS="label" WIDTH="20%">Separable Portion:</TD>
<TD WIDTH="25%" CLASS="fieldlabel">30056120</TD>
</TR>
<TR>
<TD CLASS="label">Work Order:</TD>
<TD CLASS="fieldLabel">1</TD>
<TD CLASS="label">CSA Number:</TD>
<TD CLASS="fieldLabel">4117298</TD>
</TR>
<TR>
<TD CLASS="label">Current CSA Status:</TD>
<TD class="fieldLabel">
Draft</TD>
<TD CLASS="label">Initiated By:</TD>
<TD CLASS="fieldlabel">CONSTRUCTOR</TD>
</TR>
<TR>
<TD CLASS="label">Issue Number:</TD>
<TD CLASS="fieldlabel">1</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<SCRIPT type="text/javascript">
function showQuote(sequenceNo) {
var f = document.mainForm;
switch (parseInt(sequenceNo)) {
case 10001:
f.command.value = "doCsaViewPSDetails";
break;
case 10002:
f.command.value = "doCsaViewDRDetails";
break;
case 10003:
f.command.value = "doCsaViewLSDetails";
break;
default:
f.sequenceNo.value = sequenceNo;
f.command.value = "doCsaViewDIDetails";
}
doSubmit(f);
}
function showMaterialQuote(sequenceNo) {
var f = document.mainForm;
f.sequenceNo.value = sequenceNo;
f.command.value = "doCsaViewMatDetails";
doSubmit(f);
}
//NDCG:For Link to Non Catalogued material screen
//NDCG:Add:Start
function showNonCatMaterialQuote(sequenceNo) {
var f = document.mainForm;
f.command.value = "doCsaViewMatExDetails";
f.sequenceNo.value = sequenceNo;
doSubmit(f);
}
//NDCG:ADD:End
</SCRIPT>
<INPUT type="hidden" name="sequenceNo">
<BR>
<TABLE border="0" cellspacing="1" cellpadding="0" class="table" width="100%">
<TR align="middle">
<TD rowspan="2" class=colHeader>Type</TD>
<TD colspan="3" class=colHeader>TCSS Calculated</TD>
<TD colspan="3" class=colHeader>Quoted</TD>
<TD colspan="3" class=colHeader>Approved</TD>
<TD rowspan="2" class=colHeader>View</TD>
</TR>
<TR align="middle">
<TD class=colHeader>Value</TD>
<TD class=colHeader>GST</TD>
<TD class=colHeader>Price</TD>
<TD class=colHeader>Value</TD>
<TD class=colHeader>GST</TD>
<TD class=colHeader>Price</TD>
<TD class=colHeader>Value</TD>
<TD class=colHeader>GST</TD>
<TD class=colHeader>Price</TD>
</TR>
<TR>
<TD class=cell>1. PENRITH - Generic Land & Building - Project</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD class=cell align="center" nowrap>
<IMG SRC="/global/res/images/view_white.gif" width=44 height=18 onmousemove="window.status='View Item'" onmouseout="window.status=window.defaultStatus" ALT="View Item" BORDER=0>
<IMG SRC=/global/res/images/material.gif width=16 height=16 border=0 onmousemove="window.status='Catalogued Material'" onmouseout="window.status=window.defaultStatus" alt='Catalogued Material'>
<IMG SRC=/global/res/images/material.gif width=16 height=16 border=0 onmousemove="window.status='Non Catalogued Material'" onmouseout="window.status=window.defaultStatus" alt='Non Catalogued Material'>
</TD>
</TR>
<TR>
<TD class=cell>Daywork Rates</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD class=cell align="center" nowrap>
<IMG SRC="/global/res/images/view_white.gif" width=44 height=18 onmousemove="window.status='View Item'" onmouseout="window.status=window.defaultStatus" ALT="View Item" BORDER=0>
</TD>
</TR>
<TR>
<TD class=cell>Lump Sums</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD nowrap class=rightcell>$0.00</TD>
<TD class=cell align="center" nowrap>
<IMG SRC="/global/res/images/view_white.gif" width=44 height=18 onmousemove="window.status='View Item'" onmouseout="window.status=window.defaultStatus" ALT="View Item" BORDER=0>
</TD>
</TR>
Attempts:
driver.find_element_by_css_selector("a[href='javascript:showQuote('10003')']").click()
driver.find_element_by_xpath("//a[#href="javascript:showQuote('10003')"]").click()
driver.find_element_by_partial_link_text('showQuote('10003')').click()
driver.find_element_by_css_selector('[href^=javascript:showQuote('10003')]').click()
driver.execute_script('showQuote('10003')')
Did you tried by using xpath something like below
//tbody/tr[5]/td[11]/a/img
i know taking positions of tr and td like 5, 11 is not appropriate if they go on changing. but try once to see is it able to click or not.
You can try like this
//a[starts-with(#href, 'javascript:showQuote') and contains(#href, '10003')]
If you are using firefox browser then use firebug with firepath add-on to check if it is fetching required unique element or not.
Thank You,
Murali
You need to escape the quotes to make it work:
driver.find_element_by_css_selector("[href='javascript:showQuote(\\'10003\\')']").click()
Or with a literal string:
driver.find_element_by_css_selector(r"[href='javascript:showQuote(\'10003\')']").click()