I am not getting to click on href link - robotframework

I am trying to click on Href link but with no success.
This is the HTML of the page I am trying to click:
And here is the code that I tryed to use.
Welcome Page Should Be Open
Location Should Be ${WELCOME URL}
Title Should Be OrangeHRM
Click Link id=welcome
Wait Until Element Is Visible id=welcome-menu 8
#Click Link href=https://opensource-demo.orangehrmlive.com/index.php/auth/logout
Click Link xpath://a{test()='logout'}
I tried with "href" and "xpath", but both give the error:
No keyword with name XXXXXX found.
Can you please tell me what I am doing wrong?

The error is because you only have a single space between Click Link and the xpath. You need two or more spaces to separate a keyword from its arguments.
Also, xpath://a{test()='logout'} is not a valid xpath expression. You need to change the curly braces to square brackets, and change test to text. You also need to change logout to Logout.
xpath://a[text()='Logout']
For Click Link, you can also just specify the link text or href, for example:
Click Link Logout

Related

Can robot framework click on plain text?

I have a need to click on plain texts a few times to activate a module.My code is
FOR ${index} IN RANGE 6
Log ${index}
Wait and Click Element text='SNAPSHOT'
END
And html block is
<div _ngcontent-lxw-c204=""><span _ngcontent-lxw-c204="">Versio: 5.8.4-SNAPSHOT</span><span _ngcontent-lxw-c204="" class="Test-version"></span><!----></div>
But always the error is cannot find the text .
From the code snippet, I would suggest doing it like this. Instead of using text attribute, I would use XPath expression.
Click Element //*[contains(text(), "SNAPSHOT")]
I don't know the keyword Wait and Click Element. Can you please provide me with more info about this keyword?

SeleniumLibrary Click button/link doesn't work

Click Link href=http://www.tays.fi gives the error message:
"Link with locator 'href=http://www.tays.fi' not found."
But the item does exist on my page:
< a class="ot-landingpage__link" href="http://www.tays.fi" id="yui_patched_v3_11_0_1_1562143051415_173">www.tays.fi< / a >
What am I missing here? Any ideas, please?
The problem with your code is that href= is not a valid locator prefix.
Click link by default will search the id, name, and href of all anchor elements, so you can give the href without the prefix:
Click link http://www.tays.fi
Click Link expects a locator, not the href.
In your case
Click Link id=yui_patched_v3_11_0_1_1562143051415_173
OR
Click Link class=ot-landingpage__link
See documentation
http://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Click%20Link

Google Tag Manager tracking 404 page without unique URL

I'm trying to find a way to use Google tag manager to fire a tag only when a 404 page is reached. The problem is that the 404 pages do not have "404" in the URL because there is no redirect.
For instance, if you entered:
www.example.com/ofiwefoign
This is not a page on the website, and you see the 404 page telling you that the page could not be found. However, you aren't seeing www.example.com/404.
Since the URL could be anything, I need another way to get the tag to fire. I apologize if this question seems silly, but I'm having a hard time figuring it out.
I was wondering if I could possible track by H1 or title tag, which would include "404"
Thanks!
Yes, you can grab content from the page. Here is an example (looking at document.title):
Click on the tag to go to the Edit Tag screen.
On the right, under Firing Rules click on the + Add button.
Select Create new rule.
For Rule Name, name your rule something like "404 Page".
Under Conditions select "New macro..".
For Macro Name name the macro something like "404 title tag".
For Macro Type select "Custom Javascript".
In the Custom Javascript textarea, enter the following:
function () {
return (document.title.indexOf('404')!=-1)?'true':'false';
}
This will return a string value of "true" if the title tag contains "404", or "false" if not. You didn't specify what your title tag actually looks like, so you may need to adjust this to fit what you expect your title tag to contain.
Click Save to save the macro details, and you should now see {{404 title tag}} in the dropdown back on the previous screen where you are creating the rule.
Set the operator dropdown to equals and in the text field to the right, enter in "true" (no quotes).
Click Save to save the rule.
Click Save at the bottom of the Edit Tag page to save the tag settings.
On the top-right of the tag overview page, click Publish to publish the changes, and you should be good to go.

Selenium WebDriver - how to verify multiple lines text

I have an html page with following contents:
<center>
This is Login page.
<br>
Please click below link to Login.
<br>
Login
</center>
How can I verify all the static text above using one webdriver command?
I tried these but none of it works :(
driver.findElement(By.xpath("//*[contains(.,'This is Login page.<br>Please click below link to Login')]"))
driver.findElement(By.xpath("//*[contains(.,'This is Login page.\nPlease click below link to Login')]"))
Anyone know how to do it?
You can do:
webDriver.findElement(By.id("<ID of center tag>")).getText().contains("This is Login page.Please click below link to Login.Login");
Feel free to use a locator of your choice instead of By.id.
Basically getText() of any WebElement returns the textual content of the node, stripped of all the HTML tags and comments.
This is more a limitation of XPath than Selenium.
I do not see why you are using the global XPath selector there, a better XPath selector would be:
By.XPath("//center");
If it's the only "center" tag on the page, or even:
By.XPath("//center[contains(text(), 'This is a Login page'")
The /r and /n characters will be retained if you do it through code instead of blindly searching for it in XPath.
How to find the texts if the texts has space inbetween them.
<br>
<br/>
Please click below link to Login.
<br>
Login
</center>
You can do with "\n"
return getText(supportText).contains("Information:" + "\n" +
"This page is for use by the TECHNICAL TEAM only. Following links will be active, only if you have access (subscription) to those modules.");

How to click on Toolbar element with Sahi for Test Automation?

Web page contain a button with some text for example "Test". This button actually is a toolbar element. (class ="tbButton" id="id",text="Test") and redirects to a certain table when press on it.
When I tried to use the following click methods, the button did not react.
browser.div("Test").click();
browser.click("id");
browser.click("");
browser.div("id").click();
browser.byId("id").click();
browser.containsText(browser.byId("id"),"Test");
browser.div("Test").in(browser.table("Generar")).click();
browser.byXPath("//div/Test").click();
Could anybody suggest me an alternative methods that is able to resolve the above problem?
Try with:
browser.xy(browser.div("Test"), 10, 10).click();
This will click a little inside the div.

Resources