Clicking a 'homepage' link in robot framework - selenium

I am writing test scripts using the Robot Framework & Selenium2Library for testing a web application.
The problem I have right now is that after the user has logged in, my script does not click the 'homepage' link to proceed to the Homepage, the application just disappears and command prompt gives me 'passed' results.
I want the script to click the link and then proceed to the Homepage,This is my code:
ClickHomePage
Click Link xpath=//*[#href="itinerary.php"]
I would appreciate your help. Thank you!

I have seen things like this generally when running tests on selenium. They could be really fast. I sometimes have to use breakpoints and debugging if I really want to see things happening during the test.
Unless you have another line of code after clicking the link, that is where the execution will end. Therefore, if you do want to see the homepage you may need to include a line a code that interacts with the homepage or simply a wait statement after clicking the link.

Try this code another way.
*** Variable ***
${profile} https://web.facebook.com/xxx
*** Keywords ***
Click Profile
[Arguments] ${xpath}
Click Element ${xpath}
*** Test Cases ***
Go To ${profile}
Hope to help.

Related

Seleniumlibrary command not working with Ride?

The issue I'm having is with the command Go Back from the selenium library within RIDE.
I have tried to input the Go Back command into a test script im running. The website should then simulate a click on the back button within the browser (chrome). It however does not seem to work while it does tick off the step as done and passed. I googled some stuff and found out sometimes the browser isnt ready loading when trying to perform the next command and thus it could create an issue. Because of this i tried to implement the Set Selenium Implicit Wait 10 seconds command
In the img link below (can't post the img because im not 10 reputation) you can see that I have the command Go Back and Set Selenium Implicit Wait 10 seconds. Neither however seem to work (notice that while the timer is suppose to wiat 10 seconds. it is marked as completed in 00:00:00.003
https://gyazo.com/fa18566997436989ab5a6503b9064965
I noticed that both come from the seleniumlibrary and while installed and imported (or Close Browser would not work) neither works. I'm not sure what im doing wrong here. In the picture below is how i wrote it down in the testcase.
https://gyazo.com/7d914c7c74999177ae2dca4a02d4a4bb
Any help would be much appreciated into making the bowser use the back button and/or explaining why certain aspects of the seleniumlibrary don't seem to work.
See the implicit wait section. It can be read like "the maximum time when waiting to find the element". When you use the Go Back keyword, there is no element to wait for, so it is immediate.
See here a complete example (that would work as long this question is on the first results page):
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Move Back On Browser
Open Browser https://stackoverflow.com/questions/tagged/robotframework%2bselenium?tab=Active Chrome
Scroll Element Into View xpath=//a[.='Seleniumlibrary command not working with Ride?']/../..//div[contains(#class, 'excerpt')] # Scroll to excerpt, because Cookie Policy ovelay is over URL element
Capture Page Screenshot active_questions.png
Click Link xpath=//a[.='Seleniumlibrary command not working with Ride?']
Capture Page Screenshot target_question.png
Set Selenium Implicit Wait 10 seconds
Go Back
Capture Page Screenshot after_go_back.png
[Teardown] Close Browser

Click LinkedIn share button using Robot framework selenium library

I am a newbie in using robot framework.I would like to click linkedin share button using selenium library. From my understanding linkedin share button is of type submit and value Share. can someone suggest how to use click element or click button for this. Thanks.
Here is a snippet to help you get started:
*** Settings ***
Library Selenium2Library
*** Test Cases ***
Click share
Open Browser
... url=https://put-your-link-here
... browser=googlechrome
Click Button Share
Just put the right URL there, choose the browser you want to use, and check the name of the button. You can give this a go saving it to a file test.robot, for example, and run it with:
pybot test.robot
From there, the Documentation is your best friend.
I found an answer to my question. Before clicking an element should make sure that the element is visible. So below is the code
Wait Until Element is Visible css=input[value="Share"]
Click Element css=input[value="Share"]

Selenium cannot click tab in magento module detail page

I'm trying to validate data using selenium version 1.0.9 in magento grid and its detail page.
First, I walked through Selenium IDE from login page to module detail page and click the tabs available there. Eventually, IDE generates PHP codes so I put the code into proper location.
Note: Here, I have clicked the two tabs so that the events get recorded into selenium IDE.
Then, I run the code from command prompt using following command:
phpunit --configuration /var/www/tests/phpunit_test.xml
I got the error (something like):
ERROR: Element //a[#id='test_tabs_form_section']/span not found.
I modified the code and tried to open the detail page before executing click to above link i.e. "test_tabs_form_section", I am getting same error.
Another strange this is if I verify any text of detail page and remove the code that calls click to module detail tabs, it is works, not sure why?
But I really want to open detail page and click to tab, get forms element values using xpath and validate the data.
Can somebody help me, please?
Any help or suggestion is highly appreciable!
Looking forward to hear from stackoverflow geeks!
Thanks
In case this helps anybody:
I found out more things work if firebug is active. This actually makes sense cause firebug will show the final DOM tree in all it's debugging screens, so it's possible selenium is now able to reconstruct the element path because firebug altered the internal DOM.
If something doesn't work with the default element selection created by Selenium IDE, try switching it over to xpath:id-relative. You're already using that in your question, so maybe you there's an even better selector or you will need to resort to using clickAt instead of click.

Element link not found in Selenium

I am executing a simple recorded script in Selenium , in which i just search a page in Google and then click it , but when Run that recorded script it is giving me the "Error [error] Element link not found".
And following is the Script which i am running,any help would be very useful.
New Test
New Test
open
/
type
q
Bill Gates
click
link=Bill Gates: Chairman
click
link=Bill Gates: Chairman
I got the same error message while going through the tutorials online. I found out that the scripts were running too fast for FF to load the links. If you slow down the playback by moving the green button on the Fast-Slow bar to somewhere in the middle the scripts run without any errors.
I guess I know the answer. It might be bcz of any javascript error(you can see that on the status bar at the
Right corner(IE)) or that link element might not be placed correctly in the box(box model).
Here you can use
Selenium.focus("link=text")
:selenium.keyPressNative("10") . It presses the enter key.but while selenium is executing this statement
Do not change the focus from your AUT (don't touch the mouse).
In IDE ,just paste the above statement on click().
Well, I don't think you have to slow the speed down. You know the problem is caused by clicking on the link before it is available, so you could add an extra command waitForVisible (e.g. link=Bill Gates: Chairman) before the clickAndWait command.
Im assuming you are using Google instant as there is no "click search button" command, the link is probably not preset because selenium is not waiting for Google instant to respond or the javascript to render the link. If you manually add in a click command to search it should solve it.
My solution is almost the same as Cuongs. Though I change the speed by using a command and change it back afterwards.
Before you click the link, you can set the speed to slow:
Command: setSpeed
Target: 3000
You can change the speed afterwards again to ~1000
I also had same problem. I did two things which fixed the problem. I changed the speed in Selenium IDE from fast to slow (located at top left of IDE), and I minimized the IDE after hitting play button. I guess for people using only one monitor, minimizing Selenium IDE would help the test find the thing it is looking for; for ppl with two screens, opening Selenium IDE in one screen, and opening browser in another screen would be best.
Info: Installing this plug-in (Selenium IDE: Flow Control) fixed lots of unexpected errors for me while playing with Selenium IDE:-
https://addons.mozilla.org/en-US/firefox/addon/flow-control/?src=dp-dl-othersby

Automation of DOH Robot tests interrumped by Pop-up message

In order to automate DOH tests during our build process, I use Selenium RC to launch different browsers (IE and Firefox) on a server placed on a different domain than the build machine. Each browser is directed to our runTests.html in order to start DOH.
Sometimes, when a test that uses doh.robot starts, the following message is shown:
"DOH has detected that the current web page is attempting to access DOH, but belongs to a different domain than the one you agreed to let DOH automate. If you did not intend to start a new DOH test by visiting this Web page, press Cancel now and leave the Web page"
but since these tests are unattended it just sits there waiting for someone to click OK, and Selenium times out (in IE 8 it seems like the pop-up disappears automatically but the robot does nothing afterward).
As I said, it doesn't always happen. After you click OK on the Pop-up, the message will stop showing, and the message can go away for several sessions, but then it will show again in which seems to be an arbitrary way.
Does anyone knows a way to prevent this pop-up from showing?
This is probably not the correct way to do it, but in util/doh/robot/DOHRobot.java, you may be able to modify the code to not check that or always simulate pressing "OK". I haven't tried it myself, but I may also need to do that for some of our automated testing.
When the DOH robot is initialized, it first tries to click in the upper left corner of the page you are trying to test. If you obscure this div (you can see it with firebug), then the message will pop up. I think the problem is that your page isn't always loading up quick enough.
It is somewhat of a challenge to fix this. I haven't used DOH in awhile, but I don't think there is any way you can use a setTimeout to fix this. (You can try using setTimeout on the doh.run command, but it might be the case that the DOH robot clicks that div before parsing any doh commands.)
Another thing you might be able to do is add a sort of "wait" command to Selenium, or whatever shell command you are using to fire up the system.