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.
Related
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.
I'm new to selenium
My script is to:
open one website
click one button and then open go to another website
a drop down list will be shown in the new website, i need to select one option from the list
But I failed.
The log said:
Element id=primaryroles not found
I tried to change the target to detailed HTML element, like
//html/frameset/frame/html/body/form/table/tbody/tr/td/div[#id='clientBackground']/table/tbody/tr/td[2]/table/tbody/tr[3]/td/label/select
But it failed as well.
I think the problem may be that new website did not load fully, so i add command "waitforpagetoload" value30000 but the error is time run out
I run out of my brain, please help me :)
The weirdest thing is that i could execute this single command successfully, but i play this current test suit/case, it will fail when it come to this command.
As per the snapshot (without any visibility to your script) you have shared to select from the DropDown you have to use the following Algorithm :
Open one Website
Click one button and then open go to another website
Switch to the Frame with proper WebDriverWait
Use Select Class to identify the DropDown element.
Induce WebDriverWait for your target option to render in the HTML DOM
Click on the intended option
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])
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.
I'm confused about the difference between the Click and ClickAt commands in selenium. Where can I use the ClickAt command?
Here are what Selenium IDE says about those two commands :
click(locator) Arguments:
locator : an element locator
Clicks on a link, button, checkbox or
radio button. If the click action
causes a new page to load (like a link
usually does), call waitForPageToLoad.
And :
clickAt(locator, coordString) Arguments:
locator : an element locator
coordString : specifies the x,y position (i.e. - 10,20) of the mouse
event relative to the element returned
by the locator.
Clicks on a link, button, checkbox or
radio button. If the click action
causes a new page to load (like a link
usually does), call waitForPageToLoad.
click is used when you just want to "click" on an element, like a button, a link, ...
And clickAt is used when you want to "click" on a position designated by mouse coordinates.
I suppose the second one can be useful for some "rich" applications -- I've actually never used it... On the other hand, I use click like all the time.
If you have a page with form elements, links, buttons, and stuff like that, you'll probably generally use click : it's way easier to find an element using it's id or classname than having to find it's position in pixels on the page ^^
I noticed some differences between click() and clickAt() when testing a ExtJS app.
For example, if I try to click a tab in a Ext.TabPanel, click() command does not work, although I provide it with an correct xpath, and clickAt() works fine.
Code looks like this:
click("//li[#id='tab-panel-id__second-tab-id']/a[2]/em/span/span")
doesn't work, but
clickAt("//li[#id='tab-panel-id__second-tab-id']/a[2]/em/span/span","0,0")
works.
Notice that coordinates are (0,0)
I can't figure out why this happens...
I'm testing a GWT application and it seems like I have to use clickAt if I want to click on a node in a tree widget.
Be careful when testing clickAt. Sometimes double clicking the command will cause it to show up red. You will change the line to try other alternatives but nothing will work. But then run your script and the clickAt line will be fine with whatever you type in.
There is a dojo widget at our application which only works with clickAt("//span[#id='mastheadIconBar']/span[1]/span/span","0,0").
Don't know why, but only click("//span[#id='mastheadIconBar']/span[1]/span/span") does not work.