How to resolve "Using 'Get Element Attribute' without explicit attribute is deprecated" in robot framework using selenium library - selenium

This works and returns exactly what I want:
*** Variables ***
${HOME_LOGO}= css=#header > nav > div.header-gutter > div > img
*** Keywords ***
Home logo is visible
Element Should Be Visible ${HOME_LOGO}
${logo_src}= Get Element Attribute ${HOME_LOGO}#src
log ${logo_src}
However, I am getting a WARN when I run it: Using 'Get Element Attribute' without explicit attribute is deprecated
I have tried several approaches, but have not been able to resolve the warn message AND get the information I want into ${logo_src}. I am looking for the img src.
What is the best way to either handle the warn or get the img src from the element in the xpath?
Thank you - I'm very new to robot framework and selenium but not new to test automation. Also new to stackoverflow.

They have changed how this keyword works from when it was originally designed. Instead of appending the attribute to the locator, provide it as an argument:
${logo_src}= Get Element Attribute ${HOME_LOGO} src
(note: there needs to be two or more spaces before src)

Related

Problem locating element with xpath in Selenium

I am having some troubles to locate an element with Selenium.
The page html where I'm looking for it is:
enter image description here
Specifically, I want to get the input with id='filtroDNI'. For this I'm using
WaitFluent.xpathClickable("//input[#id='filtroDNI']")
But I'm getting Method threw 'org.openqa.selenium.TimeoutException' exception. because Expected condition failed: waiting for visibility of element located by By.xpath: //input[#id='filtroDNI'] (tried for 11 second(s) with 3000 milliseconds interval)
However, If I try to get some elements above this one, I can reach the div with id='content-wrap' by using following code:
WaitFluent.xpathClickable("//div[#id='content-wrap']")
Do you have any idea of what can be happening? Also I tried with alternative xpaths but the results are the same.
Also, the page is throwing an error but after consulting it with the dev team, they said it has nothing to be with my question, the error is this one:
Uncaught TypeError: Cannot read properties of undefined (reading 'hasChildNodes')
at sorter.sort (script.js:53:12)
at sorter.reset (script.js:43:9)
at sorter.init (script.js:37:8)
at new sorter (script.js:8:77)
at histo.php:277:54
Thanks in advance
Edit:
xpathClickable method code:
/**
* <STRONG>Description:</STRONG>Waits for an element with a given xpath to be clickable.
*
* #param xpath String;
* #return WebElement
*/
public static WebElement xpathClickable(final String xpath) {
return new FluentWait<WebDriver>(myEnvironment)
.withTimeout(IMPLICIT_TIMEOUT)
.pollingEvery(RETRY_TIME)
.ignoring(StaleElementReferenceException.class,
NoSuchElementException.class)
.until(ExpectedConditions
.elementToBeClickable(By.xpath(xpath)));
}
Edit 2:
DEV team already solved the JS issue shown in console, but the xpath cannot be retrieved yet.

Cypress HTML log is terrible at indicating cy.get() DOM element names, is there any solution/workaround?

If I have the cypress code:
cy.get('[testid="cancel-button"]').should('not.exist')
cy.get('[testid="reset-button"]').should('not.exist')
cy.get('[testid="other-button"]').should('not.exist')
of course in cypress open I can see the cy.get(XXX) criteria (in my case, the testid attribute) in the log, but for cypress run the HTML log only outputs:
Expected <button.bp3-button> not to exist in the DOM, but it was continuously found.
How is this helpful at all? I will have no way of knowing which one failed because all I see is <button.bp3-button>. I want to see the testid attribute in the cy.get() call. Is there any way to get the cy.get(XXX) criteria to be where <button.bp3-button> is in the failure log?

InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression contains(text() error message

I'm getting this error message when selenium/C# program tried to click on an element in a drop down list in Dynamis365.
Inner Exception 1:
InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression contains(text(), 'Submitted') because of the following error:
TypeError: Failed to execute 'evaluate' on 'Document': The result is not a node set, and therefore cannot be converted to the desired type.
(Session info: chrome=87.0.4280.88)
My Code is:
internal void SetValues()
{
findByElement.FindByXPath("//span[contains(text(), 'Submission Pending')]").Click();
findByElement.FindByXPath("contains(text(), 'Submitted')").Click();
}
The HTML is:
<span id="id-bc19d003-2d6a-43ad-8e1b-566ecbb00647-132-statuscode6-statuscode.fieldControl-pickliststatus-comboBox_text-value" class=" ">Submission Pending</span>
I'm trying to click on Submitted choice, which do not show in HTML:DropDownList
Note: The other drop down list choices do not show in html. Only after making a choice (Submitted) it shows up in the html (replaces Submission Pending")
Submission Pending
Submitted clicked
Are you sure the page has fully loaded? Have you read the docs, specifically the 'waits' section (link below for the python version). I had this problem and simply put a 5 second delay into the code and it worked fine.
https://selenium-python.readthedocs.io/waits.html
Alternatively you may find it easier locating the element by id rather than by XPath
FindByXPath("contains(text(), 'Submitted')")
This is not a valid XPath expression! All XPath must start with the slash / character. Perhaps you meant something like:
FindByXPath("//*[contains(text(), 'Submitted')]")
Below line of code worked:
findByElement.FindByXPath("//*[./text()='Submitted']").Click();

Robot Framework: How to make Wait until keyword from selenium library return true or false

I would like to Run a keyword if an element is present on page.
I try using Selenium library's Wait Until Page Contains Element keyword, but it will always return "None", whether or not the element is present. I tried setting custom error, but that won't work either:
${condition} = Wait Until Page Contains Element ${locator} timeout=5 error=false
Run Keyword if '${condition}'=='false' click element ${some_refreshButton_locator}
Keyword click element ${locator} will run only when I make condition '${condition}'=='None'
Am I doing something wrong and how can I make a Selenium Library Wait until... keyword return true or false.
Thanks!
Wait Until Page Contains Element does not return anything but will raise error if element is not found. One workaround is to wrap Run Keyword And Ignore Error around it.
*** Settings ***
Library Selenium2Library
*** Test Cases ***
Test wait
Open Browser http://www.google.com/ gc
${result} ${condition}= Run Keyword And Ignore Error Wait Until Page Contains Stackoverflow timeout=2 error=false
Run Keyword if '${condition}'=='false' Log clicking
Close All Browsers
"Run Keyword And Return Status" can also be used to get True/False status as below:
${condition} = Run keyword And Return Status Wait Until Page Contains Element ${locator} timeout=5 error=false

Selenium webdriver: What is the substitute for browserbot?

I'm trying to convert some Selenium HTML tests to use the WebDriver 2.0 framework. According to the web site (http://seleniumhq.org/docs/03_webdriver.html), the WebDriver framework no longer supports the "browserbot" Javascript variable. So my question is, how do I convert a command like
<tr>
<td>verifyEval</td>
<td>this.browserbot.getUserWindow().s.pageName</td>
<td>Config_6_Summary_Confirm_EX</td>
</tr>
using WebDriver? When I run the command
String target = selenium.getEval("this.browserbot.getUserWindow().s.pageName")
commnand, I get an exception stating, "this.browserbot is undefined". Thanks, - Dave
I make a suggestion to following.
String target = selenium.getEval("window.s.pageName")
You can access to 'browserbot' from WebDriver's getEval by "selenium.browserbot".(not "this")
selenium.getEval("typeof(this.browserbot)"); // undefined
selenium.getEval("typeof(selenium.browserbot)"); // object
but, can not use some browserbot function.
(I don't know the deference of 'enabled function' and 'disabled function'. sorry)
"getUserWindow()" is disabled.
You can use a "window" instead of it.