17833

How to get the current URL in Robot framework?

When the 'apply' link is clicked, it opens a new browser in Robot framework. How to get current url of that page? Here is the code:

Open Server Set Browser Implicit Wait 60 Go To ${server}/jobs Element Should Be Visible xpath=.//*[@id='txtjobsearch'] Input Text xpath=.//*[@id='txtjobsearch'] ${job Title search} Element Should Contain xpath=(.//*[@class='clearfix tit-job']/div)[1] ${Job title} Element Should Be Visible xpath=(.//*[@class='btn btn-sm btn-primary btnApply'])[1] Click Element xpath=(.//*[@class='btn btn-sm btn-primary btnApply'])[1]

After this line, it opens a new window. How to get url of newly opened page and do actions like input text?

Set Browser Implicit Wait 20 Wait Until Page Contains Element xpath=.//*[@class='text-primary']

Answer1:

Have you tried using the Select Window keyword?

http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html#Select%20Window

Click Link popup_link # opens new window Select Window popupName Title Should Be Popup Title Select Window # Chooses the main window again

It seems like you wish to verify the url of the new window which should be easily possible with the following:

Select Window | url=https://google.com

Obviously you need to replace the above url with what you're expecting. Let us know how you get on.

Answer2:

Try this:

${url}= Get Location

Answer3:

getting the current URL is easy using the Execute Javascript SeleniumLibrary keyword:

${url} = Execute Javascript return window.location.href;

Recommend

  • distinguishing html with css sectors
  • JavaScript Sort by Date on table not working
  • Creating a simple, full-width, infinite carousel with jQuery
  • Bootstrap - Scrollspy scrolling skipping second to last section
  • How do I retrieve the text in a table column using Selenium RC?
  • Failing to get duration of youtube video using xpath
  • Searching an XML file using PHP [closed]
  • parsing xml and html page with lxml and requests package in python
  • How do I get the list of bad records that didn't load in Bigquery?
  • Excel's Macro-Recorder usage
  • How to handle images sent by a mobile device?
  • java inputstream
  • chrome.tabs.executeScript only fires when the Developer Console is open
  • How to render a blob on a canvas element?
  • Could not find rake using whenever rails
  • Google Custom Search with transparent background
  • How to use an array of arrays with array_map(…) in PHP?
  • FFmpeg Conversion Error
  • MongoDB in PHP using aggregate to group by _id is null not working
  • Q promise. Difference between .when and .then
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Insert into database using onclick function
  • Display issues when we change from one jquery mobile page to another in firefox
  • What is Eclipse's Declaration View used for?
  • Can I make an Android app that runs a web view in Chrome 39?
  • what is the difference between the asp.net mvc application and asp.net web application
  • To display the title for the current loaction in map in iphone
  • Web-crawler for facebook in python
  • Matrix multiplication with MKL
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • trying to dynamically update Highchart column chart but series undefined
  • Java static initializers and reflection
  • How to stop GridView from loading again when I press back button?
  • unknown Exception android
  • Binding checkboxes to object values in AngularJs
  • Observable and ngFor in Angular 2
  • Unable to use reactive element in my shiny app
  • java string with new operator and a literal