Karate UI Automation 1 - karate

How to match if the Toggle is enable or disabled in Karate?
I tried 2 things :
And match enabled('locator') == false
And match enabled('#eg01DisabledId') == false

Without the HTML it is hard to answer your question.
You could try clicking on the element using mouse().
* mouse('#eg01DisabledId').click()

Related

Swithcpage or new tab is not working in karate framework - it is always pointing to first page [duplicate]

I am having an issue with switching tabs using Karate UI. My code is as follows:
Scenario: SwitchPage Test
Given driver 'original URL'
* retry(5, 10000).waitFor('#someID')
* input('#someID', ['numbers', 'input', Key.ENTER]) // this will open the new page
* print driver.title \\ this prints the original title of the original URL
* switchPage('NewURL')
* delay(10000) // I've put this just in case but it doesn't work without it either
Then print driver.title // this still prints the original title of the original URL
Any help would be really appreciated, I think it is a great tool but I'm having difficulty with this scenario and our application opens new tabs with every module.
Thank you
Yes I know this can be hard. In 0.9.6 we have an option to switch tab by a) index and b) sub-string of the URL of that tab
Do consider submitting a simple example that can help us simulate and improve Karate if needed: https://github.com/intuit/karate/tree/develop/examples/ui-test
Finally I recommend this option if possible. If there is some way for you to derive the URL of the tab that will get opened, try to re-use the current tab, and that makes for a simpler test. See this thread for more details: https://github.com/intuit/karate/issues/1269#issuecomment-682553602
Also see: https://stackoverflow.com/a/62727612/143475

How to switch to a window (NOT TAB) in karate? [duplicate]

I am having an issue with switching tabs using Karate UI. My code is as follows:
Scenario: SwitchPage Test
Given driver 'original URL'
* retry(5, 10000).waitFor('#someID')
* input('#someID', ['numbers', 'input', Key.ENTER]) // this will open the new page
* print driver.title \\ this prints the original title of the original URL
* switchPage('NewURL')
* delay(10000) // I've put this just in case but it doesn't work without it either
Then print driver.title // this still prints the original title of the original URL
Any help would be really appreciated, I think it is a great tool but I'm having difficulty with this scenario and our application opens new tabs with every module.
Thank you
Yes I know this can be hard. In 0.9.6 we have an option to switch tab by a) index and b) sub-string of the URL of that tab
Do consider submitting a simple example that can help us simulate and improve Karate if needed: https://github.com/intuit/karate/tree/develop/examples/ui-test
Finally I recommend this option if possible. If there is some way for you to derive the URL of the tab that will get opened, try to re-use the current tab, and that makes for a simpler test. See this thread for more details: https://github.com/intuit/karate/issues/1269#issuecomment-682553602
Also see: https://stackoverflow.com/a/62727612/143475

selenium ide having problems with dynamic id

i am testing our web based application using selenium. I am having problem in a button which has dynamic id and the class is similar to the last html page so i am unable to go ahead with the testing. below is the source of the button
input id="aui_3_4_0_1_554" class="addto_cart_button" type="button" onclick="chkMaxRequestPerDay();" value="Request Quote">
I want to know how can i tell selenium ide to check with value so that it can proceed
Thanks
you can try using xpath with value,
//input[#value='Request Quote']
or
//input[#value='Request Quote' and #class='addto_cart_button']
I think something like below should also work
//input[contains(#id, 'aui_')]
or
//input[#class='addto_cart_button']
this will give you a List
loop through them and in the loop check
loop over List<Webelement> {
if( webelement.getAttribute("onclick").indexOf("chkMaxRequestPerDay") != -1) {
// here is the element. do what ever you want
}
}

How to find whether button is disabled or not in Selenium IDE

I want to check whether button is disabled or not by selenium IDE But I couldn't.
I have tried below code but it doesn't work. is there any other way to find whether button is disabled...? <tr><td>assertElementPresent</td><td>
//button[contains(text(), 'Save')]</td><td>/td></tr>
In WebDriver. There is a method isEnabled which returns true if the element is enabled else it returns false.
driver.findElement(By.id("elementID")).isEnabled();
You can use VerifyNotEditable to check your Element,Button in this case..
A button can be disabled in many ways...so you will need to think about that but a simple solution would be the assertAttribute command, using the attribute disabled.
This will ensure the element has the disabled value set, which is a common way to disable elements, but not the only way.
3 years later...I am using Selenium IDE to test whether the DOM button has been disabled:
Command: assert element present
Target: xpath=//button[#disabled]
now, I have an id for button as well, so I included that in the square bracket to ensure I am "looking" at the right button.
Hopefully, this helps somebody.
I got the answer by following way. I am getting all the style classes by using "window.document.getElementById('requiredId').className" and searching for required disable style class by following expression.
|assertExpression | javascript{storedVars['classname'].search("disabled-style-cl‌​ass") == -1} | false |
instead of is_enable use get_property :
element = driver.find_element_by_name("element_name")
prop = element.get_property('disabled')
You can check the Element visibility by using the assertVisible command.
Code:
Command = assertVisible
Target = Locator Value
Returns true if the specified element is visible, false otherwise
Determines if the specified element is visible. An element can be rendered invisible by setting the CSS "visibility" property to "hidden", or the "display" property to "none", either for the element itself or one if its ancestors. This method will fail if the element is not present.

Selenium and ckEditor

Does anybody know How I can get the ckEdtior to work with Selenium.
I'm not able to get the focus to the "html edit" field or change the value of the html field.
Does anybody has experience with this ?
Just for completing the anwser:
I got it to work with:
runScript("CKEDITOR.instances['InstanceName'].setData('<p>testContent</p>');")
It did not work with the getEval command.
When I have had a to test against WYSIWYG editors I have had to build my own mechanism to work in the content area. Normally it involves having to set the inner HTML of object and then start using the page manipulators in the tool bars.
With Selenium 2 you will be able to send keystrokes in so that they work better and a lot easier.
Working in Selenium:
selenium.runScript("for(var i in CKEDITOR.instances) { var x = CKEDITOR.instances[i]; " + " x.setData('" + texto + "'); }");
I've found a solution that worked for me. You can insert a user-extension.js (Options > options > Selenium Core Extension > Browse ) writing the following:
Selenium.prototype.doInsertCKEditor = function(locator,word)
{
this.doWaitForCondition("var x = Selenium.browserbot.findElementOrNull('//td[#id=\"cke_contents_form \"]');x != null;", "50000");
this.doRunScript("CKEDITOR.instances['"+locator+"'].setData('"+word
+"');");
}
This will add the insertCKEditor option in the Command options of Selenium IDE.