Reputation: 35
I'm trying to click this Go button but it hasn't been working.
Here's the HTML:
<a name="DERIVED_SSS_SCL_SSS_GO_1" id="DERIVED_SSS_SCL_SSS_GO_1" role="button" onclick="javascript:cancelBubble(event);" href="javascript:submitAction_win1(document.win1,'DERIVED_SSS_SCL_SSS_GO_1');"><img src="https://sims-prd.sfu.ca/cs/csprd/cache/PT_NAV_GO_1.gif" name="DERIVED_SSS_SCL_SSS_GO_1$IMG" alt="Go" title="Go" border="0"></a>
I've tried the following:
driver.find_element_by_xpath('//*[@id="DERIVED_SSS_SCL_SSS_GO_1"]').click()
driver.find_element_by_xpath("//a[contains(@href,'win1')]").click()
driver.find_element_by_id('DERIVED_SSS_SCL_SSS_GO_1').click()
Any help is appreciated. Thanks.
EDIT: Included more HTML to hopefully be able to narrow down my issue. I must be missing something contained in here.
<td height="28"></td>
<td colspan="4" align="left" valign="top">
<div id="win1div$ICField281">
<table cols="1" class="PABACKGROUNDINVISIBLEWBO" cellspacing="0" cellpadding="2" width="163">
<tbody><tr>
<td class="PAGROUPBOXLABELINVISIBLE" align="left">Group Box</td>
</tr>
<tr>
<td width="161">
<table role="presentation" id="ACE_$ICField281" cols="3" class="PABACKGROUNDINVISIBLE" style="border-style:none" cellspacing="0" cellpadding="0" border="0" width="161">
<tbody><tr>
<td width="3" height="0"></td>
<td width="132"></td>
<td width="26"></td>
</tr>
<tr>
<td colspan="2" height="1"></td>
<td rowspan="2" align="left" valign="top" nowrap="nowrap">
<div id="win1divDERIVED_SSS_SCL_SSS_GO_1"><a name="DERIVED_SSS_SCL_SSS_GO_1" id="DERIVED_SSS_SCL_SSS_GO_1" role="button" onclick="javascript:cancelBubble(event);" href="javascript:submitAction_win1(document.win1,'DERIVED_SSS_SCL_SSS_GO_1');"><img src="https://sims-prd.sfu.ca/cs/csprd/cache/PT_NAV_GO_1.gif" name="DERIVED_SSS_SCL_SSS_GO_1$IMG" alt="Go" title="Go" border="0"></a><!-- DERIVED_SSS_SCL_SSS_GO_1 --></div>
</td>
</tr>
<tr>
<td height="22"></td>
<td align="left" valign="top">
<div id="win1divDERIVED_SSS_SCL_SSS_MORE_ACADEMICS"><select name="DERIVED_SSS_SCL_SSS_MORE_ACADEMICS" id="DERIVED_SSS_SCL_SSS_MORE_ACADEMICS" size="1" class="PSDROPDOWNLIST" style="width:132px; ">
<option value=""> </option>
<option value="4010">Academic Planner</option>
<option value="3010">Academic Requirements</option>
<option value="2015">Apply/Cancel Graduation</option>
<option value="SFU4">Appointment Booking</option>
<option value="SFU5">Confirmation of Enrollment</option>
<option value="2050">Course History</option>
<option value="SFU7">Credential Completion Letter</option>
<option value="1002">Enrollment Activity</option>
<option value="1020">Exam Schedule</option>
<option value="SFU1">Link to SFU Canvas</option>
<option value="SFU2">Prev. Requested Reports</option>
<option value="SFU6">Transcript: Advising</option>
<option value="SFU3">Transcript: Official</option>
<option value="2035">Transcript: Unofficial</option>
<option value="2025">Transfer Credit: Report</option>
<option value="9999" selected="selected">other academic...</option>
</select></div>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</div>
</td>
Upvotes: 1
Views: 1186
Reputation: 407
Try this code and lets see if it works-
element = driver.find_element_by_id("DERIVED_SSS_SCL_SSS_GO_1")
driver.execute_script("arguments[0].click();", element)
update
element = driver.find_element_by_xpath('//*[@id="DERIVED_SSS_SCL_SSS_GO_1"]/img')
driver.execute_script("arguments[0].click();", element)
Upvotes: 1
Reputation: 560
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
selector = "//a[@id='DERIVED_SSS_SCL_SSS_GO_1']"
Try this firstly:
element = WebDriverWait(driver, 5).until(
EC.visibility_of_element_located((By.XPATH, selector))
)
element.click()
if it doesn't work, give this a chance:
element = WebDriverWait(driver, 5).until(
EC.element_to_be_clickable((By.XPATH, selector))
)
element.click()
Upvotes: 0