checkbox not clicked by webdriver - webdriver

I have a check box next to the text "I have read and agree to the Terms and Conditions" in a registration page. During playback, i can see
some clicking is happening . But at the end the check box is still unchecked. why is it so.
This is my HTML code
<div class="checkbox_container">
<input name="newuserXYX.agree" value="true" tabindex="106" id="newuserXYX.agree" onclick="ABC.e.reg.checkuserNameAvailability();" type="checkbox">
<input id="__checkbox_newuserXYX.agree" name="__checkbox_newuserXYX.agree" value="true" type="hidden">
<label id="registration_Agree" for="newuserXYX.agree">I have read and agree to the Terms and Conditions</label>
</div>
i wrote my testNg code as
boolean checked=driver.findElement(By.xpath("//input[#name='newuserXYX.agree']")).isSelected();
if(checked==false)
driver.findElement(By.xpath("//input[#name='newuserXYX.agree']")).click();
various approaches i tried are
#FindBy(how=How.ID_OR_NAME,using="newuserXYX.agree")
#CacheLookup
private WebElement iagreeCB;
and inside #Test
iagreeCB.click();
for all these i am getting similar result.
why i am unable to click the checkbox ?.

Your Code looks ok to me. Have you checked that the onclick-handler does not interfere with your click? Maybe the username availability check fails (BTW the T&C checkbox is a strange place to check username availability...)

Related

Using React-hook-form and I can't change the value of posts whether it is published or not

Now, I am working on the project creating a blog like site and I am facing the problem that I can't change the value whether it is published by using checkbox and react-hook-form.
It workded a weeks ago so I am thinking this is due to the update of react-hook-form but I don't know how to solve it.
I am assuming that the code below is the part to be changed.
publish is a checkbox and when checked and submitted the value of post changed to published and turned to be visible. but corrently I can't turn it to be published. It stays false which means it is not published even if it's checked.
<fieldset>
<input className={styles.checkbox} name="published" type="checkbox" ref={register} />
<label>Published</label>
</fieldset>
<button type="submit" className="btn-green" disabled={!isDirty || !isValid}>
Save Changes
</button>
this part works fine.
{!isDirty || !isValid}
I hope some kind people will help me.
Thank you.
The problem here is similar to your last question - you need to modify the usage of register to support v7:
<fieldset>
<input type="checkbox" {...register("published")} />
<label>Published</label>
</fieldset>

Checkbox click of input. Checkbox of other posts is selected

I put a check box on the input function to make a secret comment on one post and put a secret comment function.
The first post was applied without any problem, but the problem is that when I put a secret comment on the second post and click on the check box, the first check box is selected. If you click on the check box of the third post, the check box of the first post is selected. And I think it's a check box problem, but how do we solve this problem?
I didn't seem to explain well, so I brought it to the picture to see what my post looked like....;D
https://imgur.com/dCgA1Z7
<form action="#">
<p class="secretWrap">
<label for="secret">
<input type="checkbox" id="secret" class="checkbox" name="secret" />
<span>SECRET</span>
</label>
</p>
</form>
https://jsfiddle.net/4wd56t7a/
It's because you're using the same 'id' and 'for' attributes on both of your checkboxes. They need to be unique or else you're associating that label with the first instance of the id.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label

Request.Form is nothing when the object is disabled

I Google and search every article here and in the google but i cannot find anything regarding this issue. Any idea why the request.form["name here"] is nothing when the html control is disabled something like
<input type="radio" name="name here" disabled />
removing disabled would return the values. I tested this only on IE 10 not sure on other browsers.
I am looking into changing the css of the radio button but that is a different story.
Thank you.
Disabled form fields are not part of the posted data. If you disable the html control the data will not be posted.
If you want to show the data and have it posted, but not possible to edit you can set the control to readonly instead.
<input type="radio" name="name here" readonly="readonly" />

copy and pasting into web input box causes strange behavior?

i have a plain html form on a windows box running windows server 2003. I have come upon something very strange. I input items into an input box and click submit. It safely post to the next page. However if i copy and paste into the box its hit or miss. More miss then hit. WHat i mean is that the input box eventhough has values in it does not seem to post the values to the next aspx page. This is racking my brain.
<form name="sending" method="POST" action="https://xx/Retrieveimg.aspx" target="_self">
<font size="2">invoice :</font><br>
<input name="img" size="50" runat="server">
<input type="submit" value="Send" name="Send">
</form>
has anyone ever seen this behavior before?
I dont see you have an ID for the input which has a runat="server" attribute. Add an ID and try again.

Any work around for this issue -- when going back and forth between pages in Firefox the focus is lost at different points

I have a page that is rendered through xulrunner service. There is a form and a button under the form.
For accessibility requirement, I forced the focus on the text field within the form when the user navigates to this page. However, sometimes JAWS always reads the Post Comment button label. Sometimes, JAWS reads the aria-label “Enter Comments”.
Here is the code:
<body onLoad="document.addcommentform.comment.focus()">
<input type="textarea" aria-label="Enter Comments" title="{$enterComment}" name="comment" />
<input class="Button" type="submit" value="{$postComment}" />
I also tried to put a visible label on the UI like this. I did more testing and found out the behavior is pretty the same.
<label for="addcommentform">Please enter comment
<form method="get" action="{$self}" name="addcommentform">
<textarea title="{$enterComment}" name="comment" class="commentarea" </textarea>
<input class="Button" type="submit" value="{$postComment}" />
</form>
</label>
I think it is related to this known bug https://bugzilla.mozilla.org/show_bug.cgi?id=133771
But does anybody known any workaround to this issue?
I'm a Jaws user and don't know of a way around this. Since Jaws tends to create it's own model of pages in a virtual buffer things can behave slightly differently then you would expect. To confirm or disprove weather it's a Jaws specific bug I would suggest trying out NVDA an open source and quite good Windows screen reader.

Resources