Can I use waitForElementWidth Selenium command independently - testing

I just started playing with Selenium and I ran into an issue. I have a link that toggles a hidden div into view using a scroll transition. I am trying to test this function using selenium and the following steps:
1.click on toggle button
2.wait for open transition to finish
3.click on toggle button again to close
My question is can i use waitForElementWidth command for step number 2 without first storing my width with storeElementWidth? lets say I already know the final width of the div when viewable is 200px. Can i do something like:
command: waitForElementWidth
target: id=mydiv
value: 200
It seems to fail for some reason.
EDIT: I am aware that I can use the Pause command with the amount of time that the transition is set for but I am trying to stay away from set times which might change later.

I actually found the answer to this is yes you can use it independently. What i was doing wrong is that I was entering the value as a string in quotations when i just needed to enter it as simple value.

Related

Click not working on combo-box down arrow button karate UI testing

I tried clicking on down arrow button for a Combo Box (Select is not available. Its a React JS application and once I click on arrow button only list shows selection items) using below karate command but click not happened in application and no error displayed. [The same xpath worked in selenium click command,and showing unique item on Inspect search]
And waitFor("//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div")
And click("//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div")
Note: Then I tried below command
And assert('//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div').exists
and got error
javascript evaluation failed: assert('//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div').exists, :1:19 Expected , but found root
assert('//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div').exists
It would really help us if you follow this process, it is simple and should not take much time for you to give us a small snippet of static HTML (or you can mix react if really needed).
https://github.com/intuit/karate/tree/master/examples/ui-test
EDIT: you also seem to have mis-matched single and double-quotes in your code.
Also note that you should be able to fire a JS event or click by using the script() API. See this example: https://github.com/intuit/karate/tree/master/karate-core#script
So this is an alternate approach to be able to overcome any tricky situation that comes up.

Sikuli click is not effect

I'm using SikulixIDE 1.1.0 to write a script playing Yugioh game (run on Windows 10 x64).
See the main screen:
I start the game manually and then run the script as below:
switchApp("Yu-Gi-Oh! PC")
click("1477213591920.png")
My expectation is that the link named "DUEL MODE" is clicked to go to the next screen. The cursor always moves to that link, but sometimes it works, sometimes does not.
I check the log and see that Sikuli has sent click command but for some reason, the game not accept it. This is the log:
[log] App.focus: [8020:Yu-Gi-Oh!]
[log] CLICK on L(687,488)#S(0)[0,0 1366x768]
I've already tried:
doubleClick instead of click
sleep a few seconds
hover and click
But all do not work, neither.
I would expect that some of the things you have tried will help but if that's not the case you will need to identify whether the button was actually triggered or not. To do that you have to capture the next screen or any part of it that uniquely identifies it. Then you will use it a loop with a predefined number of attempts and some wait time between them and click more than once if the click didn't work. So generally something like that (pseudo code):
attempts = 3
for attempt in attempts:
click(button)
if (nextScreen is available):
break
sleep(time)
I know it's been a while but I ran into a similar problem recently.
The image was found but the click didn't work.
I'm also working on Windows 10 x86_64.
The solution was simply to execute the program as administrator.
Don't know why but now it's working..
I also had to use the double click instead of simple click for some patterns.
In adition to Eugene S Answers, if you are using SikuliX, you can try to Run in Slow Motion. Also, if the image have some effects (like brightness), you can try to use Pattern inside of exists():
if exists(Pattern("DualMode.png").similar(0.6), time_in_seconds):
click(Pattern("DualMode.png").similar(0.6))
By default, the similar() value is 0.8, so if the image have some effect and for example, the color change every second, you can set a lower value between 0 and 1.
PS: Don't forget to put the pattern inside if exists and click, because if you don't put inside of click(), could throw an Image not found error message.

Selection of Radio Button-Selenium IDE

I am new to Selenium IDE and need help in selection of radio buttons here. In my case, I am trying to generate a test case for a particular form consisting of radio buttons. When I run the command to select one of the radio buttons singly, the function works but if I run the whole test case then the radio button do not get selected and gives error of Element Id not found. Here is my html:
<input type="radio" value="0" id="ProjectSolutionsProject0" name="data[Project][solutions_project]">
My IDE command: click Target:id=ProjectSolutionsProject0 .
I tried verifyByValue , assertValue but nothing is working. Please help
From what you are describing, it appears the element may not be ready quite yet when you are trying to run the step. I have found that if an element is being dynamically generated it may take it longer to show up than Selenium wants to wait. There is a few ways to possibly fix this:
Use the waitForElementPresent command where id=ProjectSolutionsProject0 right before your current one to ensure that element has time to load.
Whatever command before that try changing it to a ...AndWait command instead to give the page time to load
Lastly you could try the waitForPageToLoad command right before this command and see if that allows the page to fully load first.
I recommend trying those options in that order to see which one would solve your problem.

Selenium IDE wait for button to be enabled

I'm testing a reasonably complex web application. I can get selenium to get things to the point where a button appears on the screen.
I want selenium to click that button after it appears. But it's not enough to use waitForElementPresent because when the button appears, it is disabled for a split second.
I need selenium to actually wait until the button is clickable before trying to click it.
I'm having no luck even trying to find out if this is possible within the IDE.
Thanks for any assistance!
It's worth re-iterating, right now I am using the IDE only. For now....
I had the same issue with Selenium IDE. I was looking for an equivalent to the ExpectedConditions.elementToBeClickable method in Selenium.
Using Selenium IDE, the following seems to work for testing an form submit input which is disabled using the disabled attribute. YMMV. Adapted as needed.
Add this Selenium IDE command before the click/clickAndWait/submit/submitAndWait command:
Command: waitForCssCount
Target: #submit-button[disabled="disabled"]
Value: 0
This css selector matches an element with id submit-button which has a disabled attribute set to 'disabled'. This command will wait until there 0 occurrences, i.e. the button is no longer disabled.
There is also a waitForXpathCount command available if you prefer to use a Xpath expression rather than a CSS selector.
Note: During testing i've noticed Selenium IDE being a little flaky and doesn't always reliably wait even with this waitForCssCount. YMMV.
I would really recommend you moving over to using webdriver 'proper', automating a complex app via just the IDE is going to cause you to end up in a mess eventually. However that is not your question and I have preached enough...
You have a few options, one might be that you get away with changing from waitForElementPresent to waitForVisible as element present just checks that the element exists on the page.
The next simplest change of that does not work is to hard code a wait into your script, hard coded waits are typically poor practice but you may get away with it if this is just a quick and dirty thing, just use the pause command (remember this takes time in milliseconds not seconds).
The last option is to use the more advanced feature waitForCondition which takes in a piece of javascript to evaluate, with this can you do extra checks on the element in question that can check for any property that identified it as ready to click.
I have seen that there is a waitForVisible command. You might want to try it.
Waiting for the DOM to load the element (waitForElementPresent) and the loaded element actually becoming visible (waitForVisible) could be two different things.
You could just use waitForElementNotPresent and give the button CSS with the disabled attribute. If the disabled attribute does not exist, the button is active, so there you have your code.
Here is the example that I used for Selenium IDE:
Command | Target | Value
waitForElementNotPresent | css= input[disabled=""]|
Your CSS can differ from your code, like having disabled="disabled" as a state, but the principle remains the same.
Using a CSS selector, I was able to use the not pseudo-selector in combination with wait for element visible.
wait for element visible
css=.btn.btn-primary:not([disabled=disabled])

How to verify presence of a image in webpage by using selenium IDE?

I am using selenium IDE 1.10.0. I am trying to check presence of image in product categories. what command should i use to verify image?
Open selenium IDE in FF browser
Right click on the image, then you see assertelementpresent command, if you do not see this command then hover over Show all available command and select assertelementpresent
Check image
try using
assertElementPresent //img
The second is xpath relative to image
Best way how to find out for yourself:
Open Selenium IDE addon
Right click the element you want to check
Hover Show all available commands
Try to find most suitable command
use that command and see what happens
There are 3 ways of doing that depending on your task (why you need this image):
1) you may wait for the image to perform some actions (e.g. wait for the button to click it): waitForElementPresent(locator). It uses timeout set in your Selenium IDE.
So when element appears, your script will execute next line. If it does not appear - this case should be processed somehow (e.g. using verify - see item 2)
2) if you need to know if image is there - you may use verifyElementPresent(locator) - it returns true or false (and you may store this value). If image is not present - test will continue running (this is important!)
3) if this image is critical - use what was suggested here already: assertElementPresent(locator) - if image is not there test will stop.
P.s. I hope you know what locator means. If not - find samples, it is easy