Text on Webpage is visible - robotframework

I am trying to make sure I have Element Text visible before I move onto the next step on my test. This is what I have tried:
Element Text Should Be //<span class="quote__summary__level">public liability only</span> Public Liability Only because the text I want to make sure are visible on the page is Public Liability Only
I have also triend <span class="quote__summary__level">public liability only</span> Public Liability Only
But I am getting this error: InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //<span class="quote__summary__level">public liability only</span> because of the following error: SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//<span class="quote__summary__level">public liability only</span>' is not a valid XPath expression.
What am I doing wrong please?
This is the element of the text on the website: <span class="quote__summary__level">public liability only</span>

Element Text Should Be xpath://span[#class="quote__summary__level"] public liability only
your locator is incorrect read how to locate element https://robotframework.org/Selenium2Library/Selenium2Library.html#Locating%20elements

Related

Robot frame work Input text : Element is not currently interactable and may not be manipulated

I am using chrome and trying to input end date to this field.
Tried this
wait until element is visible ${contract_end_date} timeout=50s
input text xpath=(//*[#name="terminatedMerchant.contractEndDate"]) ${mdy}
## input text xpath=(//*[#class="vds-input--input-text"])[3]
sometimes both xpaths works, sometimes it throws this error.
Typing text '07/07/2022' into text field
'xpath=(//*[#name="term.contractEndDate"])'.
13:18:50.275 FAIL InvalidElementStateException: Message: invalid
element state: Element is not currently interactable and may not be
manipulated (Session info: chrome=103.0.5060.114)
Element:
I cannot use ID as it keeps changing. Can you please assist in fixing this issue?
Thanks for your help.

R HTML parsing for exact match

I need to parse a HTML webpage for an exact match. Say my webpage contains the below tags and I'm only interested in scraping values associated with class = "revision-gradient" so that only the first tag is returned and not anything else, how do I go about it?
<span class="revision-gradient">90</span>
<span class="revision-gradient not_shadowed">75</span>
<span class="revision-gradient shadowed">85</span>
<span class="revision-gradient blurred">60</span>

robotframework Page Should Contain Textfield variable with random input

robotframework
I used this code:
Page Should Contain Textfield xpath: //*[contains(text(), "${date}")]
But that searches literally (Dutch: letterlijk)
The actual content could be:
value-example1${date}value-example2
So there can be some text in front and some text after the variable...
I tried this but that didn't work
Page Should Contain Textfield xpath: //*[contains(text(), "*${date}"*)]
so * before the ${date} and * after the ${date} ..... (but that doesn't work)
The reason xpath: //*[contains(text(), "*${date}"*)] didn't work is because xpath will look for text with literal asterisks. You don't need the asterisks, contains takes care of that because it looks for your requested string anywhere in the element's text.
Here is an example using contains. First, save the following to /tmp/example.html:
<html><body>
<div><h1>Some text, January 1, 2020, and more text </h1>
</body></html>
Next, save this to example.robot:
*** Settings ***
Library SeleniumLibrary
Suite Setup open browser ${URL} ${BROWSER}
Suite Teardown Close all browsers
*** Variables ***
${URL} file:///tmp/example.html
${BROWSER} chrome
${date} January 1, 2020
*** Test Cases ***
Example
Page should contain element xpath://*[contains(text(), "${date}")]
When you run this test with robot, it should pass because the element contains the string stored in ${date}.

Getting values from similar nodes using Xpath

I cant seem to get the right xpath to query "a" tag contains h3. Sample code below
<div class="ncatstories">
<a href="valuehere">
<div class="img"></div>
</a>
<h5>valuehere</h5>
<h3>titlehere</h3>
</div>
I would like to get the href value and the h3 value from the last "a" tag
<h3>titlehere</h3>]
here is my code
xpathSApply(data1,"//div[#class='ncatstories' and ./a[contains(h3)]]", function(x) c(xmlValue(x), xmlAttrs(x)[["href"]]))
where data1 is the whole data document.
however, im getting this error
XPath error : Invalid number of arguments
XPath error : Invalid expression
Error in xpathApply.XMLInternalDocument(doc, path, fun, ..., namespaces = namespaces, :
error evaluating xpath expression //div[#class='ncatstories' and ./a[contains(h3)]]
Any ideas what i need to do? thanks!
Filter down your div as normal, then filter down the anchor tag appropriately, then get the href!
//div[#class='ncatstories']/a[count(h3)>0]/#href

Multi line text box in asp.net

I have a multi line text box like :
<asp:TextBox CssClass="txtform" ID="txtWhom" runat="server" Height="78px"
Rows="10" TextMode="MultiLine"></asp:TextBox>
say I write the following text in that text box :
Dear Sir,
General Manager,
HSBC.
when I take that text in a variable in the vb.net code behind... and send it to a crystal report to show ... only ... the first line is shown... in that case only "Dear Sir," is shown ... but I want all the text ....
What Can I do ?
Use "Can Grow" option for that text object in Crystal report.
=>Right Click -> Text Object
=>Select Format Object
=>Use Can grow option in the dialog box.
It enables for variable length fields to grow vertically in the report and word wrap automatically. A maximum number of lines can be set with this option to control rogue or large data elements.
I wonder if your entered string includes carriage return & line feed chars that Crystal is not dealing with properly. You may need to strip those out or replace them with correct characters that Crystal expects.

Resources