Title: Selenium C# - Clicking on hidden checkbox and disabled anchor
Tags: c#;selenium;testing;automation
Question: The HTML I'm testing has a hidden checkbox (with display set to none) with id "ed_passengers_terms". Followed by a span that has 2 icons inside it. Based on whether or not the checkbox is checked, the icon changes and an anchor is enabled. 

HTML for checkbox:

```<div class="field checkboxes divider-half color-focus"&gt;
              <input type="checkbox" id="ed_passengers_terms" name="ed_passengers[terms]" required="required" class="form-control  hide" value="1" /&gt;
              <label for="ed_passengers_terms" class="[ short-label  is-adjusted ]  label-stack"&gt;
                <span class="fa-stack"&gt;
                  <i class="icon-checkbox fa-stack-1x sc-grey-2"&gt;</i&gt;
                  <i class="icon-tick text--h6 fa-stack-2x sc-yellow"&gt;</i&gt;
                </span&gt;
              </label&gt;
              <span class="regular text--h6 sc-dark-grey"&gt;I accept SuperCoucou's <a target="_blank" href="/terms"&gt;Terms &amp; Conditions</a&gt;</span&gt;
          </div&gt;
```

HTML for anchor:

```<a href="#" onclick="$('.ed-book-form').submit();return false;" class="disabled btn btn-action btn-block text-uppercase text--h7 semibold view-details divider-half"&gt;next</a&gt;
```

JavaScript that enables anchor:

```if ($('#ed_passengers_terms').size() &amp;&amp; $('#ed_passengers_terms').is(':checked')) {
    $('.btn-action').removeClass('disabled');
}

$('body').on('change', '#ed_passengers_terms', function() {
    if ($(this).is(":checked")) {
        $('.btn-action').removeClass('disabled');
    }
    else {
        $('.btn-action').addClass('disabled');
    }
});
```

I'm trying to create a test that enters some data on that page, then checks the checkbox to be able to click the hyperlink and proceed. 

I've tried using Click() on the span, the icon, and the div. It didn't work. 
I've tried:

```((IJavaScriptExecutor)driver).ExecuteScript("$('#ed_passengers_terms').checked = True;");
```

As a workaround, I thought I might use JavaScriptExecutor to enable the anchor and it does enable it but I can't seem to be able to click it anyway using:

```driver.FindElement(By.CssSelector(".btn.btn-action.btn-block")).Click();
```

Or using:

```driver.FindElement(By.XPath("//a[contains(.,'Next')]")).Click();
```

I need a way to be able to do the following:
1 - Preferably click the checkbox, but if that's not possible, I can enable the anchor using JavaScript so it's a non-issue. 
2 - Click the anchor so the onClick action gets executed and then it redirects to the correct page. 

P.S. I do not have access to change the HTML or the JavaScript, it's not my script, I'm only testing it

Comment: To clarify, class hide added to the input field with id = "ed_passengers_terms" has display: none;

Comment: Exact steps:
1 - Enter some data (no issues there)
2 - Check checkbox with ID ed_passengers_terms - this enables 
3 - Click on 

Comment: I don't see any element within the shared HTML with _with display set to none_. How is the `` tag related to the shared HTML? Can you update the question with the exact _Manual Steps_ you are trying to _Automate_?


Here is another answer: This is the solution I found:

```// this removes the hide class from the input which had display set to none
((IJavaScriptExecutor)driver).ExecuteScript("$('#ed_passengers_terms').removeClass('hide');"); 

// This clicked the checkbox using driver.FindElement(By.Id("id").Click(); didn't work
((IJavaScriptExecutor)driver).ExecuteScript("document.getElementById('ed_passengers_terms').click();");

// This clicked the anchor,  using driver.FindElement.Click() didn't work with class or xpath or cssSelector           
((IJavaScriptExecutor)driver).ExecuteScript("document.querySelector('.btn.btn-action.btn-block.divider-half').click();");
```

I am pretty new Selenium (3rd day) but it seems like javascriptexecutor is a bit more reliable from what I've seen so far


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 3, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2018:00:04/18/18', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<c#><selenium><testing><automation>', 'Title': 'Selenium C# - Clicking on hidden checkbox and disabled anchor', 'ViewCount': 783, 'id': 49896239, 'user_AboutMe': '', 'user_AccountId': 2822054.0, 'user_DisplayName': 'Hadya', 'user_Reputation': 35.0, 'user_Views': 3.0, 'user_id': 2425600.0}}