无法单击带有xpath和其他选择器的按钮

时间:2016-01-07 04:42:48

标签: selenium xpath selenium-webdriver

我是selenium的新手,请看下面的html,我想点击这个按钮,每当我刷新/打开这个页面时,每次都会改变id。请帮我找一下。

代码是---

<a id="d1did8122585133" class="button-position button2-gr td" rel="nofollow" onclick="callUntillDefined('showEnquiryForm', 0, 50, [{'query': 'did=8122585133&modid=ETO&ctg=164&comp=Atmiya%20Manufacturing&city=Surat&state=&country=India&modrefid=8122585133&ss=Machines%20%26%20Equipments&mcat=&modreftype=2&zoom_img=http%3A%2F%2F3.imimg.com%2Fdata3%2FCX%2FKN%2FMY-11421697%2Ffully-automatic-paper-plate-making-machines-250x250.jpg&display_image=http%3A%2F%2F3.imimg.com%2Fdata3%2FCX%2FKN%2FMY-11421697%2Ffully-automatic-paper-plate-making-machines-250x250.jpg','company':'Atmiya Manufacturing','enqu...rmType':'senEnqform','titleZoomForm':'Fully Automatic Paper Plate Making Machines','R_glusr_id':'11421697','R_custtype_weight':'149','R_title':'Fully Automatic Paper Plate Making Machines','grp':'164','displayId':'8122585133','modid':'ETO','query_text': 'SELL - Fully Automatic Paper Plate Making Machines','btn_txt':'Send Enquiry','enq_sent_color':changeColorEnquirySent,'btn_color':'button-position button2-gr td' ,'enq_enquiry_sent':'Yes'}]);recordInboundLinkS(this, 'Trac-Reply Now', 'Listing', 'Pos1', 0);">Send Enquiry</a>

2 个答案:

答案 0 :(得分:0)

您可以像下面一样创建xpath:

//a[text()="Send Enquiry"]
//a[contains(@class, 'button-position')]
//a[contains(@id, 'd1did')]

css=.button-position.button2-gr.td

答案 1 :(得分:0)

我建议你对如何定位网络元素进行更详细的研究。 您可以访问“http://www.qaautomation.net/?p=388”。