This question already has an answer here:
Karate UI: How to click a specific checkbox with same class name
(1 answer)
Closed 1 year ago.
Could you please help me?
I have a button which I need to click on. Checking it in the console, the XPath of this button returns 2 elements and I need to click on the 2nd one. So, at least these 2 locators are returning correctly my button:
("//a[#href='/organization/createorganization']")[1]
("//*[text()='mybuttonText']")[1]
I´m trying to create an automated test using Karate.
def temp = locateAll("/a[#href='/organization/createorganization']")
match karate.sizeOf(temp) == 2
temp[1].click()
My problem is that the size of temp is always 0.That means it doesn't find the locator?! Why wouldn´t find the locator? I tried also to introduce a delay, sleep time, the result is always the same. I can see visually when running the test that it doesn't click on the button. I´ve tried with both XPaths that I mentioned above and other XPaths that I could have come up with, but I get always the same - 0.
Please, do you have any ideas how to solve this?
Thanks a lot in advance.
Sounds like your locator is wrong. There's no way to tell from the limited amount of info in your question.
But try this:
* def temp = locateAll("//a[#href='/organization/createorganization']")
Or use other options: https://stackoverflow.com/a/63894989/143475
If all else fails, follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue
Related
I hope this question makes sense.
When recording in HPE UFT in my web application and selecting an option from a dropdown box made using Select2 and then running the test it fails.
It returns the next error:
Cannot identify the object "WebElement" (of class WebElement).
Verify that this object's properties match an object currently displayed in your application.
This is for version 14.03 of the tool running in a Windows machine.
And I have tried different record modes without any luck.
The code that is generated when recording the test is:
Browser("LHO DEV").Page("SITE DEV_4").WebList("WebElement").Click
Browser("LHO DEV").Page("SITE DEV_4").WebTree("select2-single-results").Select "Option Value 9"
Browser("LHO DEV").Page("SITE DEV_4").WebEdit("WebEdit").Set "Value 9"
I understand that this code won't work as Select2 as it behaves in a different way than a regular dropdown/select box.
So, I would really appreciate if anyone can give me a light in the right direction.
Well, I found a solution maybe not the desired one but at least works.
Basically, the method RunScript allows executing Javascript, in this way I was able to access the Select2 element and select the desired values.
Here is the code I used:
Browser("LHO DEV").Page("SITE DEV_4").RunScript("$('#single').select2('open')")
Browser("LHO DEV").Page("SITE DEV_4").RunScript("$('#single_element').val([66]).trigger('change')")
Browser("LHO DEV").Page("SITE DEV_4").RunScript("$('#single_element').select2('close')")
I hope anyone finds this useful in the future.
Today I have seen a question in selenium C# section where this question was posted, I try to solve that problem through WATIR coding, I have written the below code and WATIR identifies this select list as invisible.
b.goto 'http://automationpractice.com/index.php'
b.img(title: 'Faded Short Sleeve T-shirts').click
b.iframe(xpath: "//*[starts-with(#id,'fancybox-frame')]").select_list.select("L")
But If I select that same select_list through below metioned code, it works fine.
b.iframe(xpath: "//*[starts-with(#id,'fancybox-frame')]").select_list.option(text: "L").click
I don't understand what is the difference here, when I put a debug pointer, both are making a selenium call to find_element(tag_name: "select"), first one fails due to element invisible but second one passes
#Titus, #JustinKo Can you please explain me what's happening here? what's the difference?
Note: Please run it in Chrome.
Moving from a comment to an answer:
The issue is that we refactored the normal (non-select-list) way of doing it to not check for whether an element is displayed ahead of time, and put the waiting logic in the rescue block if Selenium complained. The select-list code is still checking the visibility ahead of time, and this particular select-list element is not displayed according to Selenium. Since it appears that Selenium can select options without select list showing as displayed, Watir should not be waiting for this.
I've fixed it here, and it will be working in Watir 6.13 (should be released "soon")
https://github.com/watir/watir/commit/77af164fcdecb71d8d2240110d3fb4b1dabeee4b
Since my app is online for to be tested by customer, I often meet this problem and I have to click several times on "Tiers" menu to hope it will disappear and give hand.
Here is a snapshot of the trouble :
WHen I use my app on local server (wampserver) I never meet this trouble.
I have several grids in my app and none displays this message online.
Firebug says "jquery.jqgrid.min.js" has error in line 344 (?). Used version is 4.13.5-pre dated 2016-08-27 and hosted server runs with php 5.6.8
Does somebody already met this type of trouble ?
If somebody can take some time to help me, I can give by email login and pass to test app online.
Many thanks for your kind help.
Cheers
JiheL
Thank you for reporting the issue. It would be helpful if you report the error using jquery.jqgrid.src.js instead of jquery.jqgrid.min.js, but I suppose that the only place in the code, which could produce the error is the piece of code with if ($input[0].tagName.toUpperCase() === "SELECT" && $input[0].multiple) {... (see here).
I posted the fix just now, which should eliminate the error. It includes the additional test if ($input.length > 0) {...} (see the line). I would still recommend you to examine the name and index values in colModel of your grids. It seems that your current code uses the filter with names or index, which is not from colModel or which uses some special characters. It's the only reason of the error, which one can see in console of your picture.
Selenium IDE is able to recognise the ID, Xpath, CSSPath for a link. But, Selenium RC is unable to click on the link using XPath or CSSPath or ID. I have also used "Contains Text()", but of no use. Please find below code that i am currently executing in Eclipse IDE.
selenium.open("https://abc.com");
selenium.type("UserName", "123456");
selenium.click("xpath=//form[#id='loginForm']/table/tbody/tr[7]/td/input");
selenium.click("xpath=//a[#id='_ebg9dd']");
// selenium.click("xpath=//a[contains(text(), 'Request Form')]");
Can someone please suggest any other alternative or correct the code if there is any discrepancy ?
Are you converting it using the IDE? For example, this is an Xpath selector for Java Junit 4 RC:
Seems unusual to have an id on your a-tag but if you wanted to try using 'contains' this is an example of one that works for me when I just tried it..
selenium.click("//div[#class='span5 footer-links']/ul/li/a[contains(text(), 'Submit your page')]");
I also wonder about the fact that you look to be inputting text into a 'username' field and then followed with two 'clicks'. Do you not need to either input something into another field or wait for something after the first click? Just seems like an odd series of events (may not be though, I obviously don't know the specifics of what it is you're doing.
Try this :
selenium.click("link=name_of_link_present_on_page");
I am writing a simple application that utilizes option(radio) buttons in vb6.
I am attempting to make different buttons and labels appear based on which optionbutton has been selected. I attempted to use an if statement that looks like this:
If (EditOpenTicketRadioButton.value = True) Then
label.visible = true
elseIf(...) then....
and on.
things start acting strange when I begin to type the period after EditOpenTicketRadioButton. the only options that intellisense gives me are Count, Item, LBound, and UBound. I know from internet examples It should be like the above example right? it will not run with that syntax it gives me an error that states: compile Error: Method or data member not found. then it points me to the Load method for my form...
If anyone can help me make sense of this it would be greatly appreciated.
Thanks in advance!
From the (very, very) limited information you gave, I can only assume EditOpenTicketRadioButton is a victim of extremely poor name choice and is actually an array of radio buttons.
If that's the case, you need to figure out which button you mean, and use it like EditOpenTicketRadioButton(0) or whatever.