How to open links in new tab in chrome browser
Moderators: Dorian (MJT support), JRL
How to open links in new tab in chrome browser
Hi Team,
I have two questions.
First: There is a webpage where i have to click on "Load More" button in order to load more results on the same page. The button is keep on visible until there is no more results to load are availiable. I use Xpath to click on "Load More" element in Chrome. How to identify if there is "Load More" element is availiable or not.
Second: After every result loads up, i need to open each link in the new tab to perform some task and close it and come back to result page to open next link. How to open links in new tab and switch to new tab and close it and return to previous tab. I use Chrome Browser & Xpath.
Reagrds,
Ushahra
I have two questions.
First: There is a webpage where i have to click on "Load More" button in order to load more results on the same page. The button is keep on visible until there is no more results to load are availiable. I use Xpath to click on "Load More" element in Chrome. How to identify if there is "Load More" element is availiable or not.
Second: After every result loads up, i need to open each link in the new tab to perform some task and close it and come back to result page to open next link. How to open links in new tab and switch to new tab and close it and return to previous tab. I use Chrome Browser & Xpath.
Reagrds,
Ushahra
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: How to open links in new tab in chrome browser
First: Just using FindElement to find the element should be enough - if it's not found then you'll get back zero results.
Second: If it's a link can you extract it using ChromeGetElementData and then navigate to it? Also do you really need to open it in a new tab? Can't you just 'click' it and then navigate back when done? Otherwise you could use image recognition to find the button and then issue a right click and choose from the context menu.
Second: If it's a link can you extract it using ChromeGetElementData and then navigate to it? Also do you really need to open it in a new tab? Can't you just 'click' it and then navigate back when done? Otherwise you could use image recognition to find the button and then issue a right click and choose from the context menu.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: How to open links in new tab in chrome browser
Hi,
Here i need to open links in new tab because by default the webpage show 20 results, on clicking "Load More" for 15 times, it loads up around 300 results. If i open the links in the same tab and again go back to previous page, it shows only default 20 results, here again i have to load all the links. Also loading more result on each click takes around 3-4 seconds which eventually increase the time if i keep on navigating back & forth.
Here i need to open links in new tab because by default the webpage show 20 results, on clicking "Load More" for 15 times, it loads up around 300 results. If i open the links in the same tab and again go back to previous page, it shows only default 20 results, here again i have to load all the links. Also loading more result on each click takes around 3-4 seconds which eventually increase the time if i keep on navigating back & forth.
- Dorian (MJT support)
- Automation Wizard
- Posts: 1389
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: How to open links in new tab in chrome browser
In that case Image Recognition would fit the bill here.
Yes, we have a Custom Scripting Service. Message me or go here
Re: How to open links in new tab in chrome browser
I have an idea, what if i can store all the links to a temporary notepad file and then open the link one after another to perform task? I think that would work. How can i achieve that? I mean how to send the data to notepad file in each new line and once its done, how to extract the link one by one? Any reference would help!
Re: How to open links in new tab in chrome browser
I used the above method of storing data in notepad and then opening it one by one and it worked!
I have created an empty notepad file in some directory and using it to storing and fetching the link.
But again i'm having a issue. Each time i have to clean up the notepad file whenever i run the script. Is there any alternative to it? Like deleting & recreating the file or cleaning up the data from the notepad each time while running the script.
I have created an empty notepad file in some directory and using it to storing and fetching the link.
Code: Select all
//Finding the total number of result for running the loop
ChromeFindElements>s1,xpath,/html/body/div[5]/div[1]/div[2]/div,result
//Loop to get the links in notepad
let>p=0
Repeat>p
let>p=p+1
ChromeFindElements>s1,xpath,/html/body/div[5]/div[1]/div[2]/div[%p%]/a,link
ChromeGetElementData>s1,link_1,attribute/href,strResult
WriteLn>C:\Users\user\desktop\sample.txt,nWLNRes,%strResult%
Until>p=%result_count%
//Loop to open every link in chrome
let>p=0
Repeat>p
let>p=p+1
ReadLn>C:\Users\user\desktop\sample.txt,%p%,strLine
ChromeNavigate>s1,url,%strLine%
//Running Some Task
Until>p=%result_count%
But again i'm having a issue. Each time i have to clean up the notepad file whenever i run the script. Is there any alternative to it? Like deleting & recreating the file or cleaning up the data from the notepad each time while running the script.
- Dorian (MJT support)
- Automation Wizard
- Posts: 1389
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: How to open links in new tab in chrome browser
I was just in the process of trying to create something like that for you. Nice work thinking outside the box.
Yes, you can use DeleteFile before the loop containing WriteLn.
Yes, you can use DeleteFile before the loop containing WriteLn.
Yes, we have a Custom Scripting Service. Message me or go here
Re: How to open links in new tab in chrome browser
it is a happy sight to see owners solve their own problems as in this case. Great job solving the problem.
Although, id be negligent in not offering a tip, instead of using notepad (*.txt) why not use internal MS15 arrays to store the data. this way you dont need to find a spot for the "C:\Users\user\desktop\sample.txt", research MS15 arrays in the help manual for help
for example, since you already know the %result_count% you can dimension an array of the proper size
Then you can refer to them as
Although, id be negligent in not offering a tip, instead of using notepad (*.txt) why not use internal MS15 arrays to store the data. this way you dont need to find a spot for the "C:\Users\user\desktop\sample.txt", research MS15 arrays in the help manual for help
for example, since you already know the %result_count% you can dimension an array of the proper size
Code: Select all
ArrayDim>BADASSLINKS,result_count,string
Code: Select all
BADASSLINKS_%P%