I have got the below textfield:
<div _ngcontent-c11="" class="input-container" data-testid="my-textfield"><div _ngcontent-c11="" class="title-container-input"><input _ngcontent-c11="" type="text" ng-reflect-model="my content" class="ng-pristine ng-valid ng-touched"></div><!--bindings={
"ng-reflect-ng-if": "false"
}--></div>
I am trying to check that the textfield has the content "my content"
i have tried the below:
cy.getBySel('my-textfield').should('have.text', 'my content')
also tried:
cy.getBySel('my-textfield').should('contain', 'my content')
i have tried include also but its not working.
I am getting the below as error:
expected <div.input-container> to have text my content, but the text was ''
Does anyone have any idea why this is not working.
If i do a type it is working but verifying the textfield content is not working.
Thank you
You can thy this:
cy.getBySel('my-textfield').find('input').should('have.text', 'my content')
//OR
cy.getBySel('my-textfield').find('input').should('have.value', 'my content')
Related
My vue template:
<template>
<q-item tag="label" v-ripple>
<q-item-section>
<q-item-label class="text-mono">
{{ name }}
</q-item-label>
<q-item-label caption>{{ description }}</q-item-label>
<q-item-label
caption
class="text-red"
v-show="warning"
:key="warning"
v-for="warning in warnings"
>
{{ warning }}
</q-item-label>
<q-item-label caption class="text-red" v-show="warningMsg">
{{ warningMsg }}
</q-item-label>
</q-item-section>
<q-item-section avatar>
<q-toggle
color="indigo"
v-model="model"
:disable="isToggleDisabled"
#triggerFunc="btnToggleTrigger"
/>
</q-item-section>
</q-item>
</template>
I have the following cypress E2E test code snippet:
it('Verify Toggle Button from auto-generated page', () => {
cy.get('[data-test="toggle-setting-0"]').should("not.be.checked");
cy.get('[data-test="toggle-setting-0"]').click();
cy.get('[data-test="toggle-setting-0"]').should("be.checked"); // XXX
});
The status validation fails AFTER the click(). However, cypress browser UI shows that the slider button is clicked. The error message:
Timed out retrying after 4000ms: expected '<label.q-item.q-item-type.row.no-wrap.q-item--clickable.q-link.cursor-pointer.q-focusable.q-hoverable>' to be 'checked'
What do I miss?
The <input> is within the element that has the data-test attribute.
You can verify the state by one of the inner element's class.
Does not seem ideal to me, but it works.
cy.get('[data-test="toggle-setting-0"]')
.find('.q-toggle__inner')
.should('have.class', 'q-toggle__inner--falsy')
cy.get('[data-test="toggle-setting-0"]')
.find('input')
.check({force: true});
cy.get('[data-test="toggle-setting-0"]')
.find('.q-toggle__inner')
.should('have.class', 'q-toggle__inner--truthy')
Ideally, you would check the value of the v-model variable.
I can see that the value of aria-checked is changing for the toggle. So you can so like this:
//For toggle off
cy.get('[data-test="toggle-setting-0"]').should(
'have.attr',
'aria-checked',
'false'
)
//For toggle on
cy.get('[data-test="toggle-setting-0"]').should(
'have.attr',
'aria-checked',
'true'
)
I want to make a program in Ruby that create a github repository. Everything is all right, but when i want to click the button 'create repository' after filling the repository name, nothing happened and the program stop with a timeout error.
This is the html code of the disabled button :
<button type="submit" class="btn btn-primary first-in-line" data-disable-with="Creating repository…" disabled="">
Create repository
</button>
And the html code of the enabled button :
<button type="submit" class="btn btn-primary first-in-line" data-disable-with="Creating repository…">
Create repository
</button>
And this my ruby program
repo_name = gets.chomp
repo = browser.text_field(id: 'repository_name')
repo.set(repo_name)
browser.driver.manage.timeouts.implicit_wait = 3
create_button = browser.button(type: "submit")
create_button.wait_until(&:enabled?).click
I'am pretty sure that my pb comes that when i'm landing on the page, the button is disabled, and even if i'm filling the repository_name input, my prog can't access to the button.
So do you have a solution about that ? Or maybe do you know if there is an other pb ?
Edit :
When here is the code without the waiting commands :
repo_name = gets.chomp
repo = browser.text_field(id: 'repository_name')
repo.set(repo_name)
create_button = browser.button(type: "submit").click
And when I run it, I'v got a 'Watir::Exception::ObjectDisabledException' error
("element present, but timed out after 30 seconds, waiting for #
<Watir::Button: located: true; {:type=>"submit", :tag_name=>"button"}> to be enabled (Watir::Exception::ObjectDisabledException)"
I think below code might work for you
browser.text_field(id: 'repository_name').set("repo_name")
browser.send_keys(:tab)
And as Justin mentioned in his answer, click the create repository button as below:
browser.button(type: "submit", visible: true).click
The problem is that there are multiple submit buttons on the page. You can see this by retrieving a collection of buttons:
# Button text:
browser.buttons(type: 'submit').map(&:text_content)
#=> ["Set status", "Sign out", "Create repository"]
# Disabled status:
browser.buttons(type: 'submit').map(&:disabled?)
#=> [true, false, false]
browser.button(type: "submit") returns the first submit button on the page, which is the disabled "Set status" button.
The "Create repository" button is actually the last one on the page. A more specific locator for the button is required. Some options:
# By text
browser.button(text: 'Create repository')
# By visibility (since the other 2 are hidden by default)
browser.button(type: "submit", visible: true)
When I do this
pp form
I get
{buttons [imagebutton:0x49cc436 type: image name: go value: ]}>
How do I submit when the button is a image? Since this won't work
button = form.image_with(:class => "go")
and the css
<input type="image" src="/images/btn_search_3.gif" name="go" class="go" alt="Sök">
Did you try:
form.submit form.button
Make an effort to look at the mechanize docs first before posting questions please.
I want to incorporate the Aviary editor into WordPress posts so that people can click an edit button for the image in the post, edit it and save it. Aviary has provided code for the last two, but I do not know how to pass the HTML ID and URL of the image in the post in an input tag for the edit button. I know this is basic, but I am not a programmer, so I would sure appreciate your patience and feedback. Thanks.
Here is the input static code Aviary provides:
<!-- Add an edit button, passing the HTML id of the image and the public URL of the image --><p>
<input type='image' src='http://images.aviary.com/images/edit-photo.png' value='Edit photo'
onclick="return launchEditor('imageid', 'url');" /></p>
I need to know how to pass the ID and URL for the last line of the code. Thanks so much for any feedback you can offer.
the imageid is the div id to use by aviary, you just need tu create
<div id="imageid"></div>
An to get the image url you can to like this
<?php
$image = wp_get_attachment_image_src($post->ID);
$url = $image[0];
?>
<input type='image' src='http://images.aviary.com/images/edit-photo.png' value='Edit photo' onclick="return launchEditor('imageid', '<?php echo $url; ?>');" /></p>
I assume that you will place it in attachment page
OK i have a weird one
I have a check-box that is visible on the page and is click-able. But when i view source it says:
<input disabled="disabled" type="checkbox" class="billingCheck" />
my code to is follows:
browser.checkbox(:class => 'billingCheck').set
I get the following error:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-2.0.4/lib/watir/element.rb:84:in
`asse rt_enabled': object {:class=>"billingCheck"} and is disabled
(Watir::Exception: :ObjectDisabledException)
I tried to use the following but it passed right over the code.
if
browser.checkbox(:class => 'billingCheck').visible?
browser.checkbox(:class => 'billingCheck').set
end
Any ideas? Thanks in advance.
Try this:
browser.checkboxes(:class => 'billingCheck').each {|checkbox| checkbox.set if checkbox.visible?}