I have been trying to fill a login page using Cypress and the fields are listed under a shadow DOM. I can get to the shadow (I believe) but finding the #email (CSS) does not happen and times out. Can someone help me and tell what am I missing or doing wrong? BTW tried the same with Playwright as well but no success (App is CANVAS/Flutter and not very friendly exposing locators and interaction with tools)
Looks like I am not getting the right element [email/password]. It gives assertion error and never finds #email/#current-password
it('Edison Launchpad ', function(){
cy.visit('https://staging.edisoninteractive.tv');
// cy.get('body > :nth-child(17)').type('asadW#abc.com')
cy.get('flt-glass-pane')
.shadow
cy.get('#email')
cy.type('asadW#abc.com')
cy.get('#current-password')
cy.type('jdkjdkjdkdjdkjdkjdkjdkjd')
.should('contain.text', 'email');
})
Related
I'm currently on the latest package 1.18.4 and having issues switching to an iframe during test execution.
Each time t.switchToIframe() is called, the following error is displayed:
Content of the iframe in which the test is currently operating did not load.
This happens even though i can clearly see the iframe has loaded, even placing a length wait of 60 seconds when landing on the page for testing purposes.
This rough code below should be runnable and reproduce the problem:
import { Selector, t } from "testcafe";
fixture(`Quick Test`);
test
.page(`https://www.terrific.ie/dealer/bradys-of-castleknock/finance/45784/13295`)(
`Quick Test`,
async () => {
await t
.click(`.submit-outer`)
.expect(Selector(`.car-summary-box`).visible)
.ok()
.expect(Selector(`.cw-finance-plugin.plugin-loaded`).visible)
.ok()
.switchToIframe(`.cw-finance-plugin.plugin-loaded`)
.click(`.cw-checkmark`)
.debug();
});
In general, there are two steps to switch to iframe. The first step is getting a selector with an iframe, but if the selector doesn't exist, you will get another error. The next step is getting contentWindow with a native getter. The error probably occurs on this step, but I can't reproduce this case with your iframe example. Could you share a full test example that illustrates this error?
Also, you put the content of the iframe between the tags, but it doesn't work like this. You need to set the path to the document in the src attribute of the iframe.
I am trying to automate Salesforce application Using Selenium and getting NoSuchelementException though XPATH is correct and valid for particular object. When i have searched the issue, it might be reason for Shadow DOM.
For EX:
So XAPTH i have written like,
driver.findElement(By.xpath("//input[#name='Name']")).sendKeys("Jams");
or
driver.findElement(By.xpath("//input[#id='input-299']")).sendKeys("Jams");
This XPATH is highlighting in Console as well. But while automating it throws nosuchelement error.
So while checking for ShadowDOM option, am getting option like this for Name Object.
#shadow-root(user-agent)
Shadowroot DIV
-- nothing mentioned in div. it just open and closed tags.
How to automate this?
You can check if there are any iframes in your Dom. Simply do //iframe in your page developer mode(F12)> elements tab > search (Ctrf+F) area. If there are any, you will get the number of iframes.
Now if your textbox is in any of iframe use below code to go inside particular iframe first
driver.switch_to.frame("<name or Id of frame>")
then come out to frame use below:
driver.switch_to.parent_frame()
Also, if the issue is not related to frames check below for shadow-root related issue:
you can check below for shadow-root element ( Question is for Java, but you can co-relate):
How to interact with the elements within #shadow-root (open) while Clearing Browsing Data of Chrome Browser using cssSelector
The website contents are mostly created now using javascript. You may have to wait for certain elements to load before doing anything to it.
https://seleniumbyexamples.github.io/wait
I am writing an automation script for an avatar upload module with the following CSS locator:
input[accept="image/png,image/jpeg,image/gif,image/bmp"]
I am using Robot Framework's Wait Until Element Is Visible keyword to look for the locator above but is unsuccessful with the error:
Element 'css=input[accept="image/png,image/jpeg,image/gif,image/bmp"]' not visible after 30 seconds.
Increasing the timeout also doesn't work. Using the same in Chrome Dev Tools would successfully find the element. My guess is that the commas/slashes are messing with Robot's locator parsing. My question is: What is the correct way to write the locator?
Though present in the DOM, an element may not be visible/rendered. This is very often the case with file upload input elements - the UI renders something different, a button, div that had applied styling and fits in better with the overall design.
Thus a check is it visible will rightfully fail. Change your pre-usage approach to validate the input is in the HTML - this is actually the same as what you did in the browser's dev tools - with the Page Should Contain Element keyword, and proceed on success.
There is no problem with the CSS locator your are using. Maybe the element is in another iframe?
I am getting Cannot locate an element using By.xpath error in Selenium using Java(IE11). I am working on a web page created using Adobe AEM(CQ5).
I have tried the following possible solutions but neither of it helped.
Tried to add wait.
Switch to active window.
Tried even on Chrome.
Bring focus on element.
Currently using the absolute path (/html/body/div[4]/header[1]/div[1]/div[2]/div[5]/div[1]/nav/ul[1]/li[3]/a) but also used relative path (.//*[#id='cq-gen188']/nav/ul/li[3]/a).
Also searched whether there is any iframe involved. Unfortunately there was none.
To find the xpath, I have used FirePath plugin in Firefox. When i search for the element using the xpath in Firefox, i am successful. But when i execute the code i get the error.
If you are in the correct IFRAME then you can use
driver.findElement(By.id("cq-gen188"));
Remember that ID is always unique and that's a core assumption for all of the libraries in the authoring UI whether it is from core AEM framework or from custom components.
Your problem may be due to incorrect IFRAME as AEM neatly makes the UI look like a seamless window but there are IFRAME in place to facilitate various authoring navigation experiences.
I am getting this error:
org.openqa.selenium.ElementNotVisibleException: You may only interact with visible elements
when I use HtmlUnitDriver. It works for URL, after that when I start with
driver.findElement(By.cssSelector("#from_city_typeahead")).sendKeys("bangalore");
such statements, it gives the above error. Help me to solve this issue.
You can do the same action with javascript:
webdriver.executeScript("document.getElementById('elementID').setAttribute('value', 'new value for element')");
Visibility does matter in case of standard visible browsers. But it's doesnt matter for javascript in case of any of browsers.