Question
Deloitte and Touche LLP
US
Last activity: 29 Jun 2017 13:52 EDT
Issues with finding the 'Next' button element
Hello,
I'm using Selenium to test my PEGA application and am running into a specific issue with finding the button element in the harness. I have a simple data entry form page and I am able to use Selenium to populate those fields. I have no issues finding the xpath for those elements, but I am 'unable to locate the element' for my 'Next' button. The 'Next' button is part of the page harness and when use 'Live UI' I am unable to select the 'Next' button directly. Additionally, when I 'inspect element' and copy the xpath for that button, Selenium will not recognize that xpath. I have attached a screenshot of the problem and the corresponding code when I click 'inspect element'. Does anyone know why this isn't working for that specific button and what a potential work-around can be?
Thanks.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Deloitte and Touche LLP
US
I have found the answer to my own question ...
The issue lies with the different <iframe> IDs PEGA generates for each section of the page layout. So, if you are interacting with different sections of the application then you might be in a different <iframe> ID and therefore Selenium will need instruction to 'switch to' that particular iframe...
In order to find the next button along with other elements on the page, I needed to switch to the iframe by particular ID... code below as example:
driver.switchTo().frame(findElement(driver, By.id("PegaGadget1Ifr"));
After that I was able to find the element:
findElement(driver, By.cssSelector("nobr > span > button.Strong.pzhc"), timeOutInSeconds).click();
I have found the answer to my own question ...
The issue lies with the different <iframe> IDs PEGA generates for each section of the page layout. So, if you are interacting with different sections of the application then you might be in a different <iframe> ID and therefore Selenium will need instruction to 'switch to' that particular iframe...
In order to find the next button along with other elements on the page, I needed to switch to the iframe by particular ID... code below as example:
driver.switchTo().frame(findElement(driver, By.id("PegaGadget1Ifr"));
After that I was able to find the element:
findElement(driver, By.cssSelector("nobr > span > button.Strong.pzhc"), timeOutInSeconds).click();
You will need to switch back and forth between different iframe id's when interacting with elements on the page.
Pegasystems Inc.
IN
Hi,
Even if you cannot identify the element using Live UI, you can find and element with selnium and perform the actions . I think which you are using a screen flow(Next >>) button here. If that is the case use the button(Next >>) to identify element uniquely. Example is below. I am getting div here which is child of Next >> button'r and you should be able to click on it.
//div[contains(text(), "Next")]
Please let me know if this helps or let me know what xpath you are using in selenium to identfy button
Kalyan Uppalapati
Rulesware
US
Hi
Does your script fails because is not able to find the xpath (not present) or because of timeout (not able to do a click) if is not able to do a click try this instead
WebElement element = driver.findElement(By.xpath("yourxpathvalue"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);
Guillermo Colorado
Deloitte and Touche LLP
US
Hello Guillermo,
It cannot locate the xpath for that button. The <div> it is nested inside is present, but the button itself is not present.
Rulesware
US
Hi Dennis
have you added any logic related to make sure the element is present before doing click on it? also i notice that this button has this class name "Strong pzhc" is this unique ? if it is have you try to look for the element by class name instead
could you also please share the error that the console output
Guillermo Colorado
Deloitte and Touche LLP
US
Hi Guillermo,
Here are 2 screenshots of the error log.
As you see, I've tried both using the direct xpath and the CSS selectors for that class to try and find that element. The element does not exist on the page when Selenium runs.
Again, I suspect it has something to do with how PEGA is loading the frame and button itself using javascript.
Carelon Global Solutions India LLP
IN
Hi,
In general for some of the default buttons in harness, you will find only the div tags and no other button tags embedded within them. I had a similar situation and I wanted to make the button gets clicked by getting the class name. However I was unable to do so.
But if we can change the format of the button, then we will get a <div> tag with class name as the format we mentioned apart from the previous common class names like strong-pzhc etc. With this class name, I made use of document.getElementByClassName and took the first the resultant from the array as the nedded button.
It worked for me. Hope it works for you too.
Thanks,
Praveen.
Deloitte and Touche LLP
US
Hi Praveen,
Searching by class name does not find the element. The error log says 'no element found by class name _____"
Additionally, searching by 'data-element-id' also does not find the element.
Carelon Global Solutions India LLP
IN
Deloitte and Touche LLP
US
Praveen,
Can you explain what you mean by 'change the format' ? What would you like me to do exactly? The button is inside of a harness in the class PegaGov.
Edit: I can locate the <div> element that the button in nested inside.
Carelon Global Solutions India LLP
IN
Hi Dennis,
I am sharing my observation with a similar issue in the below attachment.
Hope it helps:-)
Thanks,
Praveen
Pegasystems Inc.
US
Hi Praveen,
Unfortunately your attachment is not viewable. Could you please add a new reply and add your document as an attachment instead?
Thanks in advance!
Carelon Global Solutions India LLP
IN
Hi Marissa,
Please find the attachment which I added in my last reply.
Thanks,
Praveen.
X & G Inc
US
If you are using Selenium with IEDriverServer, make sure that the Xpath for HTML element is unique. If the system could locate multi-elements with the given XPath, IEDriverServer will return "No element found error" while Chrome driver will return the first element.
Accepted Solution
Deloitte and Touche LLP
US
I have found the answer to my own question ...
The issue lies with the different <iframe> IDs PEGA generates for each section of the page layout. So, if you are interacting with different sections of the application then you might be in a different <iframe> ID and therefore Selenium will need instruction to 'switch to' that particular iframe...
In order to find the next button along with other elements on the page, I needed to switch to the iframe by particular ID... code below as example:
driver.switchTo().frame(findElement(driver, By.id("PegaGadget1Ifr"));
After that I was able to find the element:
findElement(driver, By.cssSelector("nobr > span > button.Strong.pzhc"), timeOutInSeconds).click();
I have found the answer to my own question ...
The issue lies with the different <iframe> IDs PEGA generates for each section of the page layout. So, if you are interacting with different sections of the application then you might be in a different <iframe> ID and therefore Selenium will need instruction to 'switch to' that particular iframe...
In order to find the next button along with other elements on the page, I needed to switch to the iframe by particular ID... code below as example:
driver.switchTo().frame(findElement(driver, By.id("PegaGadget1Ifr"));
After that I was able to find the element:
findElement(driver, By.cssSelector("nobr > span > button.Strong.pzhc"), timeOutInSeconds).click();
You will need to switch back and forth between different iframe id's when interacting with elements on the page.