1

I am attempting to automate class registration.

The relevant section of HTML for the page displays as such:

<form id="SearchClasses" name="selectedStatusForm" action="/more/SearchClasses.action" method="post" class="checkboxButtonForm">
<input type="checkbox" name="enrollmentStatuses" value="E" checked="checked" id="enrolledCheckBox"/><input type="hidden" id="__checkbox_enrolledCheckBox" name="__checkbox_enrollmentStatuses" value="E" />

<script type="text/javascript">

var enrolledCheckBox = function()
{
   var updateHiddenFields = function()
   {
       hiddenCheckbox.checked = button.get("checked");
   }

   var params = { label: "Enrolled", name : "enrollmentStatuses", type : "checkbox", value : "E" };
   var onclick = function(){  
      updateHiddenFields();
             YAHOO.mis.student.Topics.onEnrollmentFilterChangedEnrolledValue.fire();
     };
   params.onclick = {};
   params.onclick.fn = onclick;
   params.onclick.obj = null;
   params.onclick.scope = false;

   var button = new YAHOO.widget.Button("enrolledCheckBox", params );
   var originalCheckedStatus = button.get("checked"); 
   button.set("checked", true);
   var hiddenCheckbox = button.createHiddenFields();
   button.set("checked", originalCheckedStatus);
   updateHiddenFields();

   return button;
}();
</script>

There are also buttons under the same form with other values, but I am trying to select value "E". Given that each registration needs to be personalized to each student, the button is seen this way when logged into the page:

<tr id = "StudentCartList_classSectionListRow_0_header" class = "classRow">
<td class = "classSelection">
<input type = "hidden" name= "enrollmentRequestItems[0].classNumber" value="2000">
<input type = "hidden" name= "enrollmentRequestItems[0].waitList" class="waitListHidden" value= "false">
<div class = "enrollmentMenu Div">
<span id = "yui-gen26" class= "yui-button yui-menu-button enrollmentButton">
<span class = "first-child">
<button type= "button" id= "yui-gen26-button"> E </button>
</span>
</span>
<div id ="yui-gen27" class = "yui-module yui-overlay yuimenu yui-button-menu yui-menu-button-menu yui-overlay-hidden" style= "z-index: 1; position: absolute; visibility: hidden;">
</div>
</td>
<td id ="classNumber_2000" class= "classSection" onclick = "YAHOO.mis.student.Topics.showClassDetailPanel.fire({classNumber : '2072', termCode : '0955', hideAddToCartButton : 'false'})">
</td>

I don't know how to select the button. I've tried

driver.find_element_by_css_selector("input.checkboxButtonForm[value= 'E']").click();

I've also tried

selector = driver.find_element_by_name("enrollmentStatuses");
selector.click();

In the first case, the element was not found. In the second case, an "ElementNotInteractableException" was thrown.

I also thought that I might have to use the Javascript Executor, but in order to do that I'd have to select my "E" value from the button element first.

How should I proceed to successfully click the button? Thank you.

2 Answers 2

1

Try following options:

Option 1:

driver.findElement(By.xpath("//*[contains(text(),'E')]")).click();

Option 2:

driver.findElement(By.xpath("//button[@type='button' and contains(text(),'E')]")).click();
Sign up to request clarification or add additional context in comments.

Comments

0

Try this code -

# Do these imports
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()
driver.maximize_window()
wait = WebDriverWait(driver, 5)
action = ActionChains(driver)

driver.get("Your URL")

Button_Click = wait.until(EC.element_to_be_clickable((By.NAME, 'enrollmentStatuses')))
action.move_to_element(Button_Click).click().perform()

Let me know if it works.

Comments

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.