How do i Upload a file using serenity screenplay pattern - serenity-bdd

I'm working on serenity screenplay pattern.
I need to upload a file to a textbox on a webpage but I got the following error:
"TargettedAction invalid element state: Element must be user-editable
in order to clear it."
This is where I am getting the error in my code :
public const string Filepath = "C:\\Series_GRPAAA_ver1.xsls"
When(_actor).AttemptsTo(Enter.TheText(Filepath).Into(HomePage.BulkUploadFilename()));

Related

Protractor get console variable value

In Firefox browser developer tool console, I type var a = libraryform.firstname
It returns the firstname value entered by user for that form.
I am new to protractor and selenium. How can I call library.firstname in protractor to get the value of fistname?
Use Javascript Executor to execute the javascript which you able to get them working in developer console against your application.
For e.g.,
this returns web-element which retrieved through javascript executed in browser.
var element = browser.executeScript("document.getElementById('identifier1')");
Refer this page for more examples
If this single line returns required value in browser console, then the protractor code should be some thing like this,
var name = browser.executeScript('return libraryform.firstname')
If you need too many lines of js, you can specify with semicolon separated,
var name = browser.executeScript("var element=$('.dropdown-toggle').eq(0); return element.text();")

Selenium - FileNotFound in OpenFileDialog

After clicking a button on a page, a file dialog opens up.
I wrote the following code to send keys:
Driver.SwitchTo().ActiveElement().SendKeys(
"\"Q:\\OneDrive\\Documents\\Production\\01-Intro.mp4\""
);
The file is there and the path is correct but I catch:
System.InvalidOperationException: 'invalid argument: File not found : "Q:\OneDrive\Documents\Production\01-Intro.mp4\"
Any clues on how to fix that?
You can directly send the file location to the input element which handles the upload.
driver.findElement(path to input).sendKeys(location of the file);
In your case try with one double quote:
Driver.SwitchTo().ActiveElement().SendKeys("Q:\\OneDrive\\Documents\\Production\\01-Intro.mp4");

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

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)

JDI UI Test Automation Framework Simple Java example project - run test

I am download Simple Java example project
Run SimpleTest
I see error
Error:(12, 17) java: cannot find symbol symbol: method domain()
location: #interface
com.epam.jdi.uitests.web.selenium.elements.pageobjects.annotations.JSite
Error:(12, 1) java: annotation
#com.epam.jdi.uitests.web.selenium.elements.pageobjects.annotations.JSite
is missing a default value for the element 'value'
I'm changing #JSite(**domain** = "https://epam.github.io/JDI/") to #JSite(**value** = "https://epam.github.io/JDI/")
In the end, I got an error
"ERROR: Can't download latest driver for CHROME. Exception null"
I changed the value driver=${driver} to driver=chrome in file test.properties,
commented on the line chrome in pom.xml
I see the same mistake
I saw the answers on the query
"ERROR: Can't download latest driver for CHROME. Exception null"
But I can not imagine where you can still specify the property of the path to the driver
System.setProperty("webdriver.chrome.driver", System.getProperty("C:\\Users\\xxxxxx\\chromedriver_win32_2.1"));
ChromeDriver d1 = new ChromeDriver();
I found the answer.
In file JDIExampleSite changing #JSite(value = "https://epam.github.io/JDI") (Remove the last slash)
In file HomePage changing #JPage(url = "/index.html", title = "Index Page") (We add "L" to htm and we get html)
In file test.properties remove the comment "drivers.folder=C:\" (I have a root chrome driver, If you are different, specify your path)
I also removed the comment from "drivers.version=2.23" in file test.properties and changed "driver=chrome" here

How to display error messages inside shematron file, during validation

I'm trying to validate my xml file with a schematron file that have (sch) extension. But I can't receive
and display the error messages that has placed between <assert test=...</assert> tags, inside my schematron file. Could you help please. Thanks a lot.
Here is my validation code block:
XmlValidator validator = new XmlValidator();
List<string> message_line = validator.ValidateXmlSchematron(xml_path, sch_file_path);