Unable to find visible field nil that is not disabled - angularjs

I'm not sure what I'm doing wrong here as I'm totally new to capybara. I can find an element with
all('.mold_table_input').last
#<Capybara::Node::Element tag="input" path="/html/body/md-content/section/md-content/md-tabs/md-tabs-content-wrapper/md-tab-content/div/div/div/md-card/md-card-content/div/form/md-content/table/tbody/tr[1]/td[1]/input">
but when I try all('.mold_table_input').last.fill_in(with: '02') I get the following error
Capybara::ElementNotFound: Unable to find visible field nil that is not disabled within #<Capybara::Node::Element tag="input" path="/html/body/md-content/section/md-content/md-tabs/md-tabs-content-wrapper/md-tab-content/div/div/div/md-card/md-card-content/div/form/md-content/table/tbody/tr[3]/td[12]/input">
I'm using angularjs on my front end. Also when I check the visibility like all('.mold_table_input').last.visible? it returns true

What version of Capybara are you using? I’m guessing < 3.7 since that’s where the ability to call fill_in on the element to be modified was added. Prior to 3.7 it would only attempt to find a valid descendant to work on. Even in 3.7+ using fill_in like you are attempting to isn’t recommended when you have a simple unique locator since it adds overhead for no reason. In this case you’re dealing with a unique element locator (element id should be unique on a HTML page) so you have no need to be using ‘all(...).last` and should just do
fill_in ‘mold_table_input’, with: ‘02’
On a related note, if you do ever need to locate an element for more complicated interaction you really should prefer find over all when you have elements that can be located uniquely. Not only will find be faster, but all has a few subtle limitations on dynamic pages.

I don't know the detail just posting to help others the following line did the trick
find('.mold_table_input', match: :first).set('06')
I was able to set the value of input field by finding first and use of set rather than fill_in

Related

How to locate element based on text()/contains criteria in Cypress.io

I need to locate an element/ verify presense of an element, based on the Text inside element, using something like:
//div[contains(text(),'<My intended text>')]
As Cypress.io do not support the XPATh yet, then how to locate it using alternate locators.
There seems to be lot of discussions around cssselectors :contains & when tried div:contains('<My intended text>') it failed to locate the element.
Given the fact that both XPATH & CSSLocators have good performance on modern browsers.
Kindly advise. Thanks
so you are looking for the parent which holds 'My intended text'?
You can do so by using:
cy.contains('My intended text')
and that's how you selected the element. Now you can use for example .click() to click on the element which holds 'My intended text'

Grails 3 "show" view with Fields plugin 2.1.0-SNAPSHOT

Stuck at a trivial problem in Grails 3.1.5: Show the fields of a domain object, excluding one of them, including a transient property. Yes, this is my first Grails 3 project after many years with previous versions.
The generated show.gsp contains
<f:display bean="rfaPdffile"/>
This will include a field that may contain megabytes of XML. It should never be shown interactively. The display: false constraint is no longer in the docs, and seems to be silenty ignored.
Next I tried explicitly naming the fields:
<f:with bean="rfaPdffile">
<f:display property='fileName'/>
<f:display property='pageCount'/>
...
</f:with>
This version suprisingly displays the values without any markup whatsoever. Changing display to field,
<f:with bean="rfaPdffile">
<f:field property='fileName'/>
<f:field property='pageCount'/>
...
</f:with>
sort of works, but shows editable values. So does f:all.
In addition I tried adding other attributes to f:display: properties (like in f:table), except (like in f:all). I note in passing that those two attributes have different syntax for similar purposes.
In the Field plugin docs my use case is explicitly mentioned as a design goal. I must have missed something obvious.
My aim is to quickly throw together a prototype gui, postponing the details until later. Clues are greatly appreciated
If I understood you correctly, you want to have all bean properties included in the gsp but the one with the "megabytes of XML" should not be displayed to the user?
If that is the case you can do:
f:with bean="beanName"
f:field property="firstPropertyName"
f:field property="secondPropertyName"
And the one you don't wish to display:
g:hiddenField name="propertyName" value="${beanName.propertyName?}"
f:with
So list all the properties as f:field or f:display and put the one you don't wish to display in a g:hiddenField Grails tag
You can also try:
f:field property="propertyName"
widget-hidden="true"
but the Label is not hidden in this case.
Hope it helps
My own answer: "use the force, read the source". The f:display tag has two rather obvious bugs. I will submit a pull request as soon as I can.
Bugs aside, the documentation does not mention that the plugin may pick up the "scaffold" static property from the domain, if it has one. Its value should be a map. Its "exclude" key may define a list of property names (List of String) to be excluded. This probably works already for the "f:all" tag; bug correction is needed for the "f:display" tag.
My subjective impression is that the fields plugin is in a tight spot. It is intertwined with the Grails architecture, making it sensitive to changes in Grails internals. It is also required by the standard scaffolding plugin, making it very visible. Thus it needs constant attention from maintainers, a position not to be envied. Even now conventions for default constraints seem to have changed somewhere between Grails 3.0.9 and 3.1.7.
Performance of the fields plugin is sensitive to the total number of plugins in the app where it is used. It searches all plugins dynamically for templates.
For the wish list I would prefer stricter tag naming. The main tags should be verbs. There are two main actions, show and edit. For each action there are two main variants, single bean or multiple beans.
My answer is that at present (2 March 2017) there is no answer. I have searched the Net high and low. For the index (list) and create and edit views, the fields plugin works well enough. A certain field can be easily excluded from the create and edit views, relatively easily from the list view (by listing those that should show), and in no way I could find from the show view. This is such a common need that one would suspect it will be addressed soon. Also, easily showing derived values in the show view, like 'total' for an invoice. One can do that by adding an ordered list with a list item showing the value below the generated ordered list of values, but that is kind of a hack.
In some ways, the old way was easier. Yes, it generated long views, but they were generated and didn't have to be done by the programmer - just custom touches here and there.

Excel: apply conditional formatting if cell contains one of x strings

What I'm trying to do should be quite simple but I am getting error messages saying that conditional formatting doesn't accept this method.
So I am looking for a fix or an alternative.
What I have is a list of search texts for phone faults
screen broken
wifi not working
bluetooth dead
the dooflip isnt working
etc.
I have also set up a number of common keywords
screen
wifi
bluetooth
By comparing these two we can see that the last one doesn't adhere to any of my common keywords, and so I want it highlighted/ copied somewhere etc. so I can view and take any action.
So far I have attempted to set up conditional formatting to search the terms for the keywords and if it doesn't contain any then highlight it.
=ISERROR(SEARCH({"wifi", "bluetooth", "screen"},$H$117))
When using this I get informed that conditional formatting does not support arrays (it works fine if I only specify one search term).
If i create a table with all the keywords in and use the following it works, however it will only find direct mataches, and wont search for the word in the cell string
=ISERROR(MATCH(<cell_to_change_colour_of>, <keyword_table>,0))
So is there another way of doing this?
my answer requires MOREFUNC addon*
=REGEX.COMP(A1,"wifi|bluetooth|screen",FALSE)
this will return true if any of the words appear anywhere in cell A1. FALSE in the formula stipulates that it is not case sensitive.
Unfortunately due to Excell's stupid rules it will not work directly in Conditional Formatting box. You will need to place it in a helper column, and point the conditional formatting rule to that column.
MOREFUNC ADDON
Morefunc Addon is a free library of 66 new worksheet functions.
HERE is some information (by original author)
here is the last working download link I found
here is a good installation walk-through video

Are there any tools for recording web browser events for seleniumn2?

I am looking for something very simple. It can use the Selenium IDE recording tool, but it does not allow me to pick what kind of locators I get.
I want to use:
driver.findElement(By.className(str))
to locate things. All I need is something which watches which UI elements on a web page get clicked and writes out the class attributes of those tags.
If I use the Selenium IDE recording (and export to the right type of thing), I get:
#Test
public void testNav() throws Exception {
driver.get(baseUrl + "/");
driver.findElement(By.name("3.1.1.5.1.1")).clear();
driver.findElement(By.name("3.1.1.5.1.1")).sendKeys("dan");
driver.findElement(By.name("3.1.1.5.1.5")).click();
driver.findElement(By.linkText("Products")).click();
driver.findElement(By.linkText("Categories")).click();
driver.findElement(By.linkText("Create a Category")).click();
driver.findElement(By.linkText("Cancel")).click();
driver.findElement(By.linkText("Products")).click();
driver.findElement(By.cssSelector("a.DisplayAdminProductsLink")).click();
driver.findElement(By.linkText("Product1")).click();
There are problems with this. First, it is not give me any By.className() calls. Why? Those first 3 calls will not help me. The framework I am using puts arbitrary things into the name. How can I get it to see the class attribute?
There actually are unique words in the class attribute of all of the above tags. I design my apps so that this is so. Yet it will not use them.
Earlier I asked:
Why is it doing a "driver.findElement().click()"? This is fragile and does not
end up working.
What I need is:
elt = driver.waitFor(By.className("c")); elt.click();
This will work reproducibly.....
I am considering to be removed from the question, as the findElement() code does work. You need to set a general time-out on the driver. It is not very obvious that this can be done, but it can.
So, continuing on....
I can go to the "Options" and change the order of the "Locator Builders" in eclipse. I can put "css" at the top. Then I get:
driver.findElement(By.cssSelector("input[name=\"3.1.1.5.1.1\"]")).clear();
driver.findElement(By.cssSelector("input[name=\"3.1.1.5.1.1\"]")).sendKeys("dan");
driver.findElement(By.cssSelector("input[name=\"3.1.1.5.1.5\"]")).click();
The tags are like:
<input class="form-control LoginUsernameField" ... />
But it does not see the class attribute.... Or I can do this manually.
Selenium looks for a unique identifier to identify elements in a webpage. classNames are a very less desired option for this purpose as they are generally not unique. Ids and names on the other hand are generally unique. This might be the reason why Selenium IDE is not selecting classNames and going for other identifiers.
Selenium IDE records user actions. You would have clicked on the element for Selenium IDE to identify it and that is why you are getting driver.findElement().click().
If you want to wait for element to wait you can try implicit wait.
When you want to use driver.findElement(By.className(str)), are you sure that there is one and only one element in the webpage that is associated with a className? If that is the case you can modify the webdriver code manually to use className.

Contains an element with the target?

Is there any way only using CSS (no script) to check if an element such as a table contains another element such as with the target? I know that you can use the :target pseudo class for elements with the target, but I need the ability to select an element which contains the element with the target. If there's any way to using the :contains pseudo class to check if an element contains the target that'd be useful, however I've tried it a few different ways with no success. I know there isn't a parent selector which rules out looking for the parent of the element with the target URI. The only possible ways I can think of are using :contains and I don't think that'll even work with anything but text. If anyone knows some sort of trick or other selector that'd solve this issue, help would be appreciated.
First guess:
I'm having a hard time understanding your question, so my answer is offered on the assumption that your question is something like this:
Is there any way to style the parent of a targeted element?
And the answer is no, css works by cascading down the hierarchy, it can't cascade up; have a read of the following questions/answers for further details:
CSS Parent/Ancestor Selector
Is there a CSS parent selector?
Complex CSS selector for parent of active child
(There are others, if you search for 'css parent selectors')
Second guess:
If your question is:
can I find links that target other sections of the same page?
Then yes, you can (with css3 and/or using jQuery):
a[href*='#'] { /* css */ }
$("a[href*='#']") // jQuery selector
The href*='#' part is an attribute-selector, that searches the 'href' attribute for any occurrence1 of the quoted string '#' (the # being used to target same-page links).
If you're able to revise your question to make it more clear what you'd like us to help you with, then I'll be more than happy to try and be more use to you, but as it is I can only guess. Which is pretty much useless. =(
Footnotes:
Other options are:
starts with, eg: a[href^='http://'] which selects all links whose href begin with 'http://', and
ends with, eg: a[href$='.pdf'], which selects all links that end with the filetype .pdf.

Resources