I'm testing a reactjs app and the type() and pressKeys() commands are not working correctly. type('string') isn't entering text into the input field and pressKeys('string') is only entering 's'. I'm not sure if this is an issue with leadfoot and react in general, or the particular react app I'm testing. Here is some sample code from the page:
<div class="Select Select--multi is-searchable" data-reactid=".0.1.0.0.1.0.0.1:$languages">
<input type="hidden" data-reactid=".0.1.0.0.1.0.0.1:$languages.0" value="">
<div class="Select-control" data-reactid=".0.1.0.0.1.0.0.1:$languages.1">
<div class="Select-placeholder" data-reactid=".0.1.0.0.1.0.0.1:$languages.1.0:$placeholder">Languages</div>
<div class="Select-input " data-reactid=".0.1.0.0.1.0.0.1:$languages.1.1" style="display:inline-block;">
<input data-reactid=".0.1.0.0.1.0.0.1:$languages.1.1.0" style="width:5px;box-sizing:content-box;" tabindex="0" value="">
<div data-reactid=".0.1.0.0.1.0.0.1:$languages.1.1.1" style="position: absolute; visibility: hidden; height: 0px; width: 0px; overflow: scroll; white-space: nowrap; font-size: 14.4px; font-family: "Proxima Nova","Helvetica Neue",Helvetica,Arial,sans-serif; font-weight: 400; font-style: normal; letter-spacing: normal;"></div>
</div>
<span class="Select-arrow-zone" data-reactid=".0.1.0.0.1.0.0.1:$languages.1.4">
</div>
</div>
I can't select the first input element since it's hidden and I've tried selecting all of the available divs and the second input element. I currently have to do the following to enter text:
.pressKeys('t')
.pressKeys('e')
.pressKeys('x')
.pressKeys('t')
Any suggestions? I'm currently using a function that converts the data string to a char array and then enters each char one at a time.
Related
I'm trying to perform a Cucumber test that can click on the ng-select component (dropdown menu) and, after that, clicks on one of the options of the menu.
I've tried to use "element (by.partialLinkText('Solid Community')).click()", where "Solid Community" is the text that must be clicked. I also tried with "by.LinkedText" but it didn't work.
I can not use "by.id" or similar because the options of the menu don't have an id (the whole dropdown menu has one).
Here are some relevant parts of the code:
login.component.html:
...
<div style="margin-top: 10px;">
<ng-select class="login-select"
id="login-select-menu"
bindLabel="name"
bindValue="loginUrl"
placeholder="Select ID Provider"
dropdownPosition="bottom"
[items]="identityProviders"
[(ngModel)]="selectedProviderUrl"
style="width: 360px; height: 48px; margin-left: auto; margin-right: auto;">
<!-- DROPDOWN TEMPLATE -->
<ng-template ng-option-tmp let-item="item">
<div style="height:40px; padding-top:10px; position: relative;">
<img [src]="item.image" style="float: left; height: 32px; width: 32px; margin-top:-5px;" />
<span style="float: left; margin-left: 10px;">{{ item.name }}</span>
<div style="clear: both;"></div>
</div>
</ng-template>
</ng-select>
<input type="text"
class="wide-text"
*ngIf="selectedProviderUrl===null"
placeholder="Enter WebID"
style="margin-top:10px; padding: 12px 10px; width: 340px; height: 16px; display: block; margin-left: auto; margin-right: auto;"
[(ngModel)]="customProviderUrl" />
<button class="wide-button" (click)="onLogin()" *ngIf="selectedProviderUrl !== undefined || customProviderUrl !== undefined" [disabled]="selectedProviderUrl===null && !customProviderUrl" style="margin-top:10px;">Go</button>
</div>
...
loginSelectMenu.feature:
#loginSelectMenu-feature
Feature: Click on login select menu
Display anything
#loginSelectMenu-scenario
Scenario: Login Page
Given I am on the login page
When I click on the login select menu
Then It should happen anything
app.steps.ts (the error is in "When"):
When(/^I click on the login select menu$/, async () => {
await page.clickOnLoginSelectMenu();
await page.clickOnSolidCommunity();
});
app.po.ts:
clickOnLoginSelectMenu() {
return element(by.id('login-select-menu')).click();
}
clickOnSolidCommunity() {
this.sleep(3000);
return element(by.partialLinkText('Solid Community')).click();
}
When identifying elements it's important to look at the rendered HTML in the DOM instead of the angular HTML template. There are a number of transformations that occur when the templates are rendered.
Also partialLinkText will search for <a> tags which contain the provided string. It does not appear you are using any a tags within your code.
If your element is of another type you should be able to use the cssContainingText locator like so
element(by.cssContainingText('div','Solid Community')).click();
I am looking for a way to have a list of checkboxes slide out from an input box when I click it. Basically what I'm looking for is a way to create an overlay form that's tethered to the input box. This image shows what I have before click (left) and what I want to happen on click (right).
Right now I have a bootstrap modal pop up on click, but obviously that's not very user friendly. Any working solution will do, from pure css to js packages. My front end currently works with just html, css, js & jquery.
I've tried the following, but that shows my checkboxes through/behind the text that's already there.
.change-search__form-container {
display: none;
position: absolute;
width: 300px;
background: #fff;
border: #000;
border-width: 1px;
}
A pure css solution based on previous answers and Pete's comments.
#myDiv{
display:none;
}
#myDiv:hover, #myDiv:focus-within {
display: block;
}
#myInput:focus + #myDiv {display:block}
<input id="myInput" placeholder="search query">
<div id="myDiv">
<input type="checkbox" id="box1">
<label for="box1">Stuff 1</label>
<input type="checkbox" id="box2">
<label for="box2">Stuff 2</label>
<br>
<input type="checkbox" id="box3">
<label for="box3">Stuff 3</label>
<input type="checkbox" id="box4">
<label for="box4">Stuff 4</label>
</div>
The DIV can be shown by using the below jQuery code
$("#searchbox").focus(function(){
$("#searchresults").show();
});
By using this code the DIV won't go away if the focus from textbox is lost
I solved the problem with the help of the comments. My CSS:
#change-search__form-container {
position: relative;
}
#change-search__dropdown-form {
z-index: 1;
display: none;
position: absolute;
width: 300px;
background: #fff;
border: #000;
border-width: 1px;
}
My jQuery:
$('#change-search__form-container').click(function () {
$('#change-search__dropdown-form').show();
});
This way the container shows on clicking the input box, and doesn't disappear when I click elsewhere (on one of the checkboxes, for example).
there is a great post for a very similar problem:
Css Focus on input div appearing
Runs for Safari and soon in chrome..
#myDiv2{display:none;}
#myInput:focus + div { display: block; }
#myDiv1:focus-within #myDiv2 { display: block; }
<div id="MyDiv1">
<input id="myInput" type="text"/>
<div id="myDiv2">
<label class="container">One
<input type="checkbox" checked="checked">
<span class="checkmark"></span>
</label>
</div>
<div style="display:none">
<span> aaa </span>
</div>
</div>
I am attempting to style my React component using a CSS style sheet. I want to change the margins to separate my elements better, but my div class seems to be broken, or I am not understanding this concept correctly. This is the output of my current code:
I would like to add space between the account name input box, and the text.
Here is my React:
renderGetAccountName: function renderGetAccountName() {
return (
<Dialog onClose={this.onGetAccountNameClose} height={300}>
<h1 style={dialogHeaderStyle}>
NAME YOUR ACCOUNT
</h1>
<span style={errorMessage}>
It is time to name your new account! Please enter your choice below, and click "OK" when you are finished.
</span>
<div classname="nameInput">
<form id="frm1" action="form_action.asp">
ACCOUNT NAME: <input type="text" name="new-account-name"></input>
</form>
</div>
<Button type='button submit' style={submitStyle}>
OK
</Button>
<span>
<button type="button">Cancel</button>
</span>
</Dialog>
);
}
Here is my CSS:
.gone
display: none
.contact
.controls
.dropdown-menu
li
border-top: 1px solid #B3B3B3
cursor: pointer
padding-top: 8 px
text-transform: capitalize
text-align: center
height: 44 px
&:hover
background-color: #EEE
.nameInput
margin-top: 50px
margin-left: 50px
Instead of using classname you must use className
Use className={"nameInput"}. The attribute is camel case.
I'm trying to make a survey webapp on heroku (javascript mostly) and the off-center text on these radio buttons is rather annoying. What's an easy way to center it and slide it off to the side a little? Formatting is all done with CSS right now. Currently how I'm formatting these radio inputs is as so....
.radio-input{
background: #D4E7ED;
padding:20px 10px;
}
You can use vertical-align: middle on label and radio button with padding-top: 1% on label for aligning text and radio button:
label {
vertical-align: middle;
padding-top: 1%;
}
.rdo{
vertical-align:middle;
}
DEMO
Here's an example I created using a similar approach that Coder outlined. It includes the background coloring you specified and it wraps the radio button and text in divs. It seemed to behave pretty well for me:
the css:
.radio-input {
padding-top:20px;
vertical-align:top;
}
.radio-input-text {
vertical-align:bottom;
}
.background {
background: #D4E7ED;
width:300px;
}
the HTML:
<div class="background">
<div class="radio-input">
<input type="radio" value="Great" id="Great" /><span class="radio-input-text">Great</span>
</div>
<div class="radio-input">
<input type="radio" value="Okay" id="Okay" /><span class="radio-input">Okay</span>
</div>
<div class="radio-input">
<input type="radio" value="Very Bad" id="VeryBad" /><span class="radio-input">Very Bad</span>
</div>
</div>
Demo
For future reference here is the final result with pixel perfect precision:
The CSS code:
._25 {
width: 21%;
display: inline;
float: left;
margin-left: 2%;
margin-right: 2%;
}
._50 {
width: 46%;
display: inline;
float: left;
margin-left: 2%;
margin-right: 2%;
}
._75 {
width: 71%;
display: inline;
float: left;
margin-left: 2%;
margin-right: 2%;
}
._100 {
width: 96%;
display: inline;
float: left;
margin-left: 2%;
margin-right: 2%;
}
label {
width: 100%;
}
input {
border: 1px solid #B3B3B3;
width: 100%;
-moz-border-radius: 3px;
}
textarea {
border: 1px solid #B3B3B3;
width: 100%;
-moz-border-radius: 3px;
}
select {
border: 1px solid #B3B3B3;
width: 100%;
-moz-border-radius: 3px;
}
And some sample HTML code:
<div class="_50">
<p><label for="in_user">Username</label><input id="in_user" type="text" value=""/></p>
</div>
<div class="_50">
<p><label for="in_pass">Password</label><input id="in_pass" type="text" value=""/></p>
</div>
Recently I've started using CSS grid systems and I find the whole process of designing a webpage much more simpler. Now I'm trying to stylize form elements but I'm having a really hard time making forms with columns, take the following example:
div (width = 400px)
form
ul
li .half
label
input (should be 200px wide)
li .half
another label
another input (should also be 200px wide)
Basically I'm applying a class that has a width attribute of 50% but putting both inputs side by side makes the row to be bigger than 100% (400px) - I guess this is because of borders, margins and paddings.
Is there any CSS grid system that I can use to have multi-column forms while still making all the form elements have the same size (inputs, selects and textareas); eg. 1 input in 1 column should have 400px while 2 columns should have 200px each.
EDIT: Wufoo has some examples of what I'm trying to do but I'm too ignorant at CSS to understand all that code and I would appreciate if someone could give me some pointers.
First off, do not use a table. Putting form elements in a table does not solve your problem and complicates your maintenance. Using tables to supplement form presentation is a sign of incompetence and complexity. It is also entirely non-semantic. Instead you might actually have to write some CSS. Honestly, if you are going to use tables for non-tabular data then don't even bother using CSS as that multiplies the complexity of maintenance.
Here are some things to keep in mind:
1) Define all your units in "em" units. Most form elements are intended to contain text. Those elements, like text fields and textarea blocks, can be increased and decreased as a feature of accessibility. This means your pixel perfect pretty CSS grid will break the moment a user changes text size on the page.
2) Don't wrap your form element in a div. Like a div, your form is a block level element. Unless the form has peer nodes under a div parent simply direct any presentation directly to the form element and not a parent element that exists only to contain the form.
3) Group your form elements. If you are floating text fields things can get all messed up if the forms are floated independently of their respective label elements. It will be easier to put an ordered list inside your form and then wrap each form element in a list item. This way you only have to worry about defining layout of the label element relative to its form control and then layout of them together by defining presentation of the list item. This method is also semantic and informs text readers of an order upon your form controls.
4) Don't use the !important declaration. This makes for a quick fix in your CSS but completely screws up inheritance and absolutely complicates maintenance. Instead take the extra time to write your code correctly the first time, so that future maintenance is a quick and minor event.
5) Don't use position absolute, unless you really know what you are doing, even if your form is set to position relative. Position absolute results in unexpected behaviors in many cases and unexpected problems.
6) To ensure your CSS code actually defines a true grid use the Firefox MeasureIt plug in. It will help you achieve stunning accuracy and save you incredible time when making your grid.
7) Do everything correctly the first time using as little code as necessary to get the job complete and present your form perfectly. Only then test your form for cross browser accuracy. Make one correction for cross browser accuracy at a time to limit unnecessary bloating to your CSS code.
Something like this may help. This is how I did it on a form.
It will take some fine tuning though to make it work at your desired width. This might help you get started though.
The CSS:
.contact ul {margin:0; padding:0; list-style:none;}
.contact li {margin-bottom:10px; overflow:hidden;}
.contact label {display:block; margin-bottom:2px;}
.contact label span {color:#999;}
.contact .input {width:592px; border:1px solid #E0E0E0; background:#F6F6F6;}
.contact select.input {border:1px solid #E0E0E0; background:#F6F6F6;}
.contact .third {float:left; width:193px; margin-right:10px;}
.contact .third .input {width:185px;}
.contact .half {float:left; width:294px; margin-right:10px;}
.contact .half .input {width:286px;}
.contact .half select.input {width:294px;}
.contact .omega {margin-right:0;}
The HTML:
<form action="/contact-us" method="post" class="contact">
<ul>
<li>
<div class="half">
<label for="name">Name:</label>
<input type="text" id="name" name="name" class="input" />
</div>
</li>
<li>
<label for="address">Address:</label>
<input type="text" id="address" name="address" class="input" />
</li>
<li>
<div class="third">
<label for="city">City:</label>
<input type="text" id="city" name="city" class="input" />
</div>
<div class="third">
<label for="state">State:</label>
<input type="text" id="state" name="state" class="input" />
</div>
<div class="third omega">
<label for="zip">Zip:</label>
<input type="text" id="zip" name="zip" class="input" />
</div>
</li>
</ul>
</form>
Here's a basic kickoff example which may be of use:
<!doctype html>
<html lang="en">
<head>
<style>
fieldset { width: 400px; padding: 1%; }
input[type=text], select, textarea { width: 98%; }
.half { float: left; width: 48%; padding: 1%; }
.full { clear: both; width: 98%; padding: 1%; }
.right { text-align: right; }
</style>
</head>
<body>
<fieldset>
<legend>Contact form</legend>
<form>
<div class="half">
<label for="name">Name</label>
<input type="text" id="name" name="name">
</div>
<div class="half">
<label for="email">Email</label>
<input type="text" id="email" name="email">
</div>
<div class="half">
<label for="zip">Zip / Postal code</label>
<input type="text" id="zip" name="zip">
</div>
<div class="half">
<label for="country">Country</label>
<select id="country" name="country"><option></option></select>
</div>
<div class="full">
<label for="message">Message</label>
<textarea id="message" name="message"></textarea>
</div>
<div class="half">
<input type="checkbox" id="copy" name="copy">
<label for="copy">Send me a copy</label>
</div>
<div class="half right">
<input type="submit" value="send">
</div>
</form>
</fieldset>
</body>
</html>
Note that I am using left-floated div's of half-width instead of unordered list items.
As you insist in using percentages, don't expect it to be pixelperfect in all browsers. If you want to have it all pixelperfect, you really need to use pixels.
I think this is what you are looking for:
http://www.alistapart.com/articles/prettyaccessibleforms/
It should help simplify your structure a little bit. It doesn't explicitly describe how to make multiple column forms, but the technique could probably expand to that with some creativity on your part.
No need for the fluid 960 system here, unless you want the form to expand and contract with the browser.
I would recommend the regular old 960 grid system for this. 960 width is great for grids because it divides evenly by 12 and 16 which allows you to set up pixel perfect three and four column layouts.
The best way to get familiar with the 960 grid system is to look at the souce css and the source of the html demo
<div class="grid_6">
<p>
contact form
</p>
</div>
<div class="grid_3">
<p>
name
</p>
</div>
I had to do something similar and ended up setting my half-columns to 46%. It leaves an extra bit of room for the padding and gets all your input fields consistently sized.
One answer is Blueprint. I have read where you don't think it's the answer, but it's still the way I would do it. All the ease of tables with all the power of CSS.
With blueprint the math is pretty easy. Let's say your form spans 10 columns.
<div id="contact-form" class="span-10">
<h3>Contact Form</h3>
<form action="contact">
<div id="form-sec-1" class="span-5">
<label>Name</label> <br/>
<input type="text" name="name" /> <br/>
<label>ZIP code</label> <br/>
<input type="text" name="zipcode" />
</div>
<div id="form-sec-2" class="span-5 last">
<label>Email</label> <br/>
<input type="text" name="email" /> <br/>
<label>Country</label> <br/>
<input type="text" name="country" />
</div>
<div id="form-sec-3" class="span-10 last">
<label>Message</label> <br/>
<textarea name="message" />
</div>
<div id="form-sec-4" class="span-8">
<input type="checkbox" name="copy"/>
<label>Send me a copy</label>
</div>
<div id="form-sec-5" class="span-2">
<input type="submit"/>
</div>
</form>
</div>
Oh wow,i was just thinking what in the world is the matter with the css world then i saw this css grid layout editors draft,http://dev.w3.org/csswg/css3-grid-align/
I still cannot explain why the css world hasn't really been thinking along such lines,what explanation can there be for the lack of such a feature in css.