Robot Frameworks - Click Element step passes, does not trigger action - frameworks

I am having an issue, where I need to click on an element that opens up a menu. The click element step is successful; however the expected action is not triggered. I have added a Sleep statement, Wait Until Element Is Visible, and Set Selenium Speed to 1s. On the Log.html page I see the screen capture where the element I attempt to click is visible. The menu that I am trying to open is inside an iframe.
Any help would be greatly appreciated.
`
*** Test Cases ***
Access Page
Set Selenium Timeout 60
Check Web Tier Enabled
Sleep 30
Capture Page Screenshot
Open Widget
Click Element ${App_Components}
Click Element ${Widget_List}
Sleep 2
Select Frame ${iFrame}
Sleep 5
Capture Page Screenshot
Open Menu
Wait Until Element Is Visible ${Menu}
Focus ${Menu}
Mouse Over ${Menu}
Sleep 5
Click Element ${Menu} <--- this step is successful, but does not triger action
Sleep 5
Capture Page Screenshot
`

Found s solution to my problem, added this as a keyword.
Click Element Using JavaScript
[Arguments] ${xpath}
${var}= Execute Javascript var xPathRes = document.evaluate("${xpath}", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); xPathRes.singleNodeValue.click();

Related

Click button is not working in protractor

I am new to angular world. I am in process of automating the angular 2
application but I am having hard time to click a button.
Options tried:
I used various selectors like xpath, CSS, buttonText but none of them is working, s/m throws a timeout message or unable to find a selector.
When I try to print the element in console it is displaying as object object.
Do I need to return the value in format of string and then attempt to click?
Or
Do I need to add any require plug in from NPM ? Please let me know
script snippet:
var resubmit=element.all(by.xpath("//BUTTON[#_ngcontent=''][text()='resubmit']")).get('0');
console.log("return"+resubmit);
resubmit.click();
Wait untill element is become clickable and then click. You do it by following:
EC=protractor.ExpectedConditions;
var resubmit=element.all(by.buttonText('resubmit')).get('0');
browser.wait(EC.elementToBeClickable(resubmit), 15000,'Not Clickable'));
resubmit.click();

WebDriverError: unknown error: Element is not clickable at point (330, 367) even after using EC.elementToBeClickable

I am writing test cases in protractor using chromedriver
I have a link which when clicked gives an overlay div pop up where I can enter few details and Add details. After adding the details again the main page and link is visible. But when I am trying to click on the main link second time I am getting
WebDriverError: unknown error: Element is not clickable at point (330, 367). Other element would receive the click:
I tried using the below code still issue is not resolved
browser.wait(EC.elementToBeClickable(link)).then(function(){
link.click().then(function(){
browser.sleep(3000).should.notify(next);
});
});
Can someone please help
I have seen this in my application before, Once you close the pop-up you have to wait for the window closing animation to finish. Your flow should be something like below
browser.wait(EC.elementToBeClickable(link),5000)
//Fill the pop-up
element(by.css('.textArea')).sendKeys('jhghaskjdhkjasd')
//close the pop-up
element(by.css('.close')).click()
//wait for the pop-up to close
browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.pop-up'))),5000)
Also as a side point, you don't need to chain all webdriverJs promises.They are already placed in queue using Protractor control flow

One Click vs Two Clicks

Scenario:
Testing web application using Protractor
Element needs to be clicked on to open another page
Designed the test to have one click on the element
Issue:
Sometimes elements needs one click and the test passes but if I run it again the same element needs double clicks
This is causing my test to fails randomly
I verified this by changing the command to have a double click in protractor and it passed.
This is causing inconsistency as I don't know when the element needs one or double clicks.
Any Suggestion is appreciated?
You may just need to put the element into focus explicitly via mouseMove() and then issue a click() action:
browser.actions().mouseMove(elm).click().perform();
Inconsistency might be because of element is not yet ready to click. So you need to wait until element become clickable and click it. Below code will help you in achieving consistency.
Code Snippet:
var EC = protractor.ExpectedConditions;
var elementToBeClick=element(locator);
var timeOut=10000;
browser.wait(EC.elementToBeClickable(elementToBeClick), timeOut).
thenCatch(function () {
assert.fail(' target element is not clickable');
});
elementToBeClick.click();
you can use browser.executeScripts to inject native javascript code into the browser and click the required button. this will execute the click event on the required element that you pass into the function
try the below code,
var elementToBeClick=element(locator);
browser.executeScript("arguments[0].click()",elementToBeClick.getWebElement())

DOM usage in QTP

During script execution a pop up won't go away, and it happens only through QTP(v12.02).
I am trying DOM to bypass the problem, the pop up event was on selection of a drop down value, so I used some code to find the correct index and use DOM to select the value
Browser().Page().WebList().Object.selectedIndex = itmindx
With this the pop up issue got resolved, but now to complete the process,I need to click the Save button which is disabled as the page didn't refreshed when the value was selected ( tried refreshing through QTP, tab out etc--didn't worked as it loads the previous value).So I used the fire event method
Browser().Page().WebList().Fireevent "onchange"
with this I ran in to the same issue of multiple pop ups. Used the following
Browser().Page().WebList().Object.onchange()
but then QTP won't executes the next line unless I hit enter externally on the pop up(multiple pop up is resovled but now QTP is stuck. I don't want to use RS.... Any solutions?
To enable the button
Browser().Page().WebButton().Object.disabled = false
Or
To hit enter for the popup
CreateObject("WScript.Shell").SendKeys("{ENTER}")
[ http://ss64.com/vb/sendkeys.html ]
Go for hitting the Enter button using SendKeys. It is not a good idea accessing DOM and change the state ourselves. There is a chance that you might miss potential defects!

Unable to locate WindowID

I am currently testing a web app using selenium rc with eclipse. I've been having issues with a single pop up window which appears when a submit button is clicked. The confirmation window appears with a single 'ok' option.
I've also tried 'chooseOKonnextConfirmation' in conjunction with .getConfirmation but eclipse tells me no confirmation exists. I've tried inspecting the window itself with firebug but have been unable to get any results.
I also tried with "selenium.selectWindow(getAllWindowIDs ()[1]);" but selenium not recognizing "getAllWindowIDs".
Could somebody please tell me how I can retrieve the windowID and the associated API commands I need to implement to get rid of this problem?
from your description, i understand that you have an ALERT window being appeared after clicking SUBMIT button but not the CONFIRMATION window.
if my understanding is correct
( you said single OK button - ALERT window appears with single OK button - CONFIRMATION window appears with OK and CANCEL buttons - there is another window javascript can generate which is CONFIRMATION.it appears with TEXT field and OK and CANCEL buttons )
so you must use accordingly.
here is what you should use
if(selenium.isAlertPresent()) {
String message = selenium.getAlert();
}
this will consume you Alert window and you can check the message displayed on Alert window if you want.
if this is not please post write your comment
It's selenium.getAllWindowIds(); note the capitalisation. Don't forget to make sure the popup has already appeared (e.g. selenium.waitForPopUp()).
Yes sudarsan is correct if you have an alert.
If you have an popup window not an alert with OK button then you have to click OK when popup appears.
If you are unable to locate the button use firebug to locate the element.