Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get URL for updated webpage URL #392

Closed
pallavkrishna opened this issue Apr 8, 2019 · 9 comments
Closed

How to get URL for updated webpage URL #392

pallavkrishna opened this issue Apr 8, 2019 · 9 comments
Labels

Comments

@pallavkrishna
Copy link

I need the url for newly launched window.

ex:
https://github.com/kelaberetiv/TagUI
click //*[@id="readme"]/div[2]/article/p[7]/a

then a new tab will be opened, i need to get the newly launced url.

kindly help
thanks in advance

@pallavkrishna pallavkrishna changed the title How to get url for newly launched window How to get url for newly launched tab Apr 8, 2019
@kensoh
Copy link
Member

kensoh commented Apr 9, 2019

Hi Pallav, I see, you mean getting the URL of the updated webpage URL.

You can use the url() helper function to do that -

https://github.com/kelaberetiv/TagUI
click //*[@id="readme"]/div[2]/article/p[7]/a
echo url()

For a list of other useful helper functions, see https://github.com/kelaberetiv/TagUI#helper-functions

@kensoh kensoh added the query label Apr 9, 2019
@kensoh kensoh changed the title How to get url for newly launched tab How to get URL for updated webpage URL Apr 9, 2019
@kensoh
Copy link
Member

kensoh commented Apr 9, 2019

Pasting Pallav's further comments in #236, the use case is for an explicit popup window, not a normal link which brings current tab to a new page.


hi Kensoh
url() returns parent tab url but i need the url of newly launched tab.
please find the example
1.http://demo.guru99.com/popup.php

2.click //a[text()="Click Here"]

3.echo url()

in step 3 it is returning the launched url (http://demo.guru99.com/popup.php) but when i perform step 2 a new tab will be opened so i need the what url is launched in step 2

@kensoh
Copy link
Member

kensoh commented Apr 9, 2019

You can use the popup step to access the new tab. But you need to know at least some keyword in the new tab to identify which tab you wants to access. More details on popup step here, click to expand the pro steps - https://github.com/kelaberetiv/TagUI#steps-description

Both examples below work because the popup tab has an 'article' keyword in URL

http://demo.guru99.com/popup.php
click //a[text()="Click Here"]
echo url()
popup articles
echo url()
http://demo.guru99.com/popup.php
click //a[text()="Click Here"]
echo url()
// use brackets if want to do many actions in popup tab
popup articles
{
echo url()
echo title()
}

So it will show the output below -

START - automation started - Tue Apr 09 2019 18:10:04 GMT+0800 (+08)
http://demo.guru99.com/popup.php - 

click //a[text()="Click Here"]
http://demo.guru99.com/popup.php
popup articles
http://demo.guru99.com/articles_popup.php

http://demo.guru99.com/popup.php - Guru99 Bank Home Page
FINISH - automation finished - 6.2s

@fez226
Copy link

fez226 commented Apr 11, 2019

hello @kensoh how i save the url on a .txt file? save url() as url.txt?

update:
solution:
newurl = url()
dump newurl to myurl.txt

@kensoh
Copy link
Member

kensoh commented Apr 11, 2019

Yep that's right. The save step is to save text from a UI element.

dump or write steps can be used to output text or variables to a file.

http://tebel.org
dump url() to myurl.txt

@pallavkrishna
Copy link
Author

http://demo.guru99.com/popup.php
click //a[text()="Click Here"]
echo url()
// use brackets if want to do many actions in popup tab
popup articles
{
echo url()
echo title()
}
Hi
Thanks a lot kensoh
The solution is working good.
I need one more help
How to close the newly launched tab. why because i need to perform some more operations in first tab.

@kensoh
Copy link
Member

kensoh commented Apr 28, 2019

Posted reply here for benefit of other users - #411

@Hassan-Ali123
Copy link

Hi! nice to see you all! I am stuck at a problem. I want to know how to navigate to a webpage by opening a new tab in the same browser window?? Actually I am extracting some data from a webpage then navigate to the specified page to use this data. But my current webpage reloads and navigates to the new url. I need to open the current webpage as well as a navigate to other webpage in a new tab, to use the extracted data. Please help me if someone can!
Thanks a lot!

@kensoh
Copy link
Member

kensoh commented May 21, 2020

TagUI does not natively support running multiple tabs unless it is initiated by the main webpage to open new tab. You can try using visual automation mode to do it the way you do manually, or you can break the automation into 2 parts. First part extract data from website 1, second part use data on website 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants