1

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="">&nbsp;</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>
4
  • Can you share the error log? Commented Aug 29, 2017 at 19:54
  • There's no error. It just doesn't click the button. Commented Aug 29, 2017 at 19:56
  • Post the url if you can to check the full html code. Commented Aug 30, 2017 at 7:11
  • I'm afraid I can't. It's for a school login so without the credentials, you won't be able to access said page. I added more HTML to the original post. Commented Aug 30, 2017 at 8:09

2 Answers 2

1

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)
Sign up to request clarification or add additional context in comments.

6 Comments

I'm not getting an error. It's just not pressing the button. I added more HTML to the original post. Hopefully that helps.
I get this error: selenium.common.exceptions.InvalidSelectorException: Message: Given xpath expression "//[@id="DERIVED_SSS_SCL_SSS_GO_1"]/img" is invalid: SyntaxError: The expression is not a legal expression.
@RubiksH -- updated it again. Please try this. It should work now.
I still get the same error. selenium.common.exceptions.InvalidSelectorException: Message: Given xpath expression "//[@id="DERIVED_SSS_SCL_SSS_GO_1"]/img" is invalid: SyntaxError: The expression is not a legal expression.
@RubiksH - There is issue with single quotes and double quotes. Please try one more time. Just copy from here and paste it in your code.
|
0
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()

3 Comments

Neither of those were able to click the button.
Which driver(Chrome or Firefox) are you using and which version of it?
I'm using Firefox geckodriver-v0.18.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.