Im testing a website and i want to know how to validate if a class contains any buttons or not or if a class or div has an image inside it
I tried this code
cy.get('.banner-square-overlay-container').invoke('button').should('have.length.gt', 0)
Invoke is for applying the function to the container.
To find a button in the container you need to use the find command.
Something like this:
cy.get('.banner-square-overlay-container')
.find('button')
.should('have.length.gt', 0)
Related
I am working on xamarin.forms. I have a content page which contains one webview which load 3rd party url(www.xyz.com) site and one button in shell.
On button click event I am trying to get user input data using
webview.eval(javascript: var data = document.getElementById('first-name').value;alert(data)).
It works fine but due to void return type I could not store data in local variable and I have a customrender(webviewrender) but don't know on shell button click event how can I get userinput data from webview
Please suggest me how do I achieve this functionality.I do not want XLab-Hybridwebview.
You'll probably need to have the JavaScript code call out to the external code when the result is available. You could then wrap that whole process in a TaskCompletionSource to make everything nice and easy to use.
can you please tell me How go from one UI to another UI on Image button click event in juce introjucer?
Basically you have to:
1.- Parent component must inherit from ButtonListener, and you must implement the buttonclicked method
void WindowComponent::buttonClicked (Button* activeButton)
{
if (activeButton == &someButton)
{
gotoOtherPage();
}
}
2.- Your "UIs" i must suppose are components, if so just do something like:
component.setVisible(false),
otherComponent.setVisible(true),
Or perhaps stash them in a TabbedComponent, hide the tabs or overlap some buttons and then just do:
tabbedComponent.setCurrentTabIndex(someIndex);
That should get you going, in case you need help to draw a button just do something like:
addAndMakeVisible (&someButton);
someButton.setBounds(...);
someButton.addListener(this);
Check out the doxygen docs, they are quite helpful.
I am working in a CakePHP application, where I am using HTML helper's image() function to show images. What I want, if it gets the image in the given path, then it will show the image, otherwise, it'll show a default image. I have that "default" image, but I don't understand where/how to define it.
Thanks
Extend the HTML helper and add the logic to the image method and override the called image with your default image if the originally requested image does not exist.
index.ctp file code
<?php
$MyImage = $post['Post']['image0']; // image0 is my db field
if (file_exists("img/uploads/posts/".$MyImage))
$MyImage1 ="/img/uploads/posts/".$MyImage;
else
$MyImage1 = "/img/uploads/posts/no-image.jpg";
echo $this->Html->image($MyImage1);
?>
Note : My post's images are stored in app/webroot/img/posts folder(default image is also in this folder.)
I am using WatiN and I need to determine if an image has been loaded. In my case I get the red X on the page but when I use...
var image = WebBrowser.Current.Image(imageName);
if (!image.Exists)
{
Assert.Fail(string.Format("Could not find '{0}' image on the page", imageName));
}
...the Assert doesn't fail because the name of the image does exist on the page. BUT it is not loaded.
Is there a way to use WatiN to eval with JQuery or something that tells me when I get the red X? I have tried every method and property of WebBrowser.Current.Image to no avail.
If i understand correctly you are trying to find the image by name attribute.
If the name attribute is "image_name_attr" (you can verify this by firebug) use this:
WebBrowser.Current.Image(Find.ByName("image_name_attr")); //constraint
If there is a class name on the image you can use:
WebBrowser.Current.Image(Find.ByClass("image_class_attr"));
The Assert is not failing because WatiN is doing exactly what it should; it is checking if the image html element exists. What you need to be checking for is if whether the file exists on the server.
Take a look at this SO question/answer - I've used this approach in the past and it worked mighty fine. Test to see if an image exists in C#
I am trying to select a link/button inside of a form, that is in a div. the way it was made is that there are two links/buttons of the same id, name etc. however they are in different forms, so the code i wanted to use is:
_myTest.Form(Find.ById("PermissionsForm")).Child(Find.ByClass("saveBtn")).Child(Find.ByText("SAVE"));
any help would be appreciated
I think this is what you need:
var button = _myTest.Form("PermissionsForm").Button(Find.ByClass("saveBtn"));
This will lookup the button having the class 'saveBtn' inside the form 'permissionsform' in your browser instance _myTest.
Have a look at this page to decide if you need to have .Button(..) or .Link(...) based on the html tag that is used in your html.
How about building a regex for the element?
Regex could something like this
Regex elementRe = new Regex("id=LnkOk href="http://stackoverflow.com");
Then you can use your code to Click this link. The Click method can be extended to accept Regex if it is not already doing that.
Let me know how this goes or if you need more info.
Cheers,
DM