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

Unable to open the URLs in the excel file using chrome #128

Open
GoogleCodeExporter opened this issue Apr 3, 2015 · 4 comments
Open

Unable to open the URLs in the excel file using chrome #128

GoogleCodeExporter opened this issue Apr 3, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

Operating system : Win 7
.Net Framework version :
Office Version : 2010
SeleniumWrapper version : 1.0.23.0

What is your issue ?
I am trying to open a list of URLs with column A but the first tab gives, 
'www.google.com/www.amazon.com' and 'about:blank' for the rest of the tabs.

For example:
URLs (Header)
www.facebook.com
www.yahoo.com
www.google.com
www.amazon.com

Code:

Private Sub cmdLoadURLs_Click()

Dim selenium As New SeleniumWrapper.WebDriver

Dim intRowPosition As Integer
Dim keys As New SeleniumWrapper.keys

selenium.Start "chrome", "http://www.google.com"
selenium.setTimeout ("120000")
selenium.setImplicitWait (5000)
intRowPosition = 2
selenium.Open Sheet1.Range("A" & intRowPosition)

intRowPosition = intRowPosition + 1

While Sheet1.Range("A" & intRowPosition) <> vbNullString
    selenium.executeScript "window.open()"
    'selenium.SendKeys keys.Control & "t"
    selenium.Open Sheet1.Range("A" & intRowPosition)
    intRowPosition = intRowPosition + 1
Wend

End Sub

Reference: 
http://www.makeuseof.com/tag/how-to-automate-firefox-or-chrome-with-vba-and-sele
nium/

Thank you!

Original issue reported on code.google.com by jonkh...@gmail.com on 10 Jan 2015 at 4:54

@GoogleCodeExporter
Copy link
Author

That's because the Urls you're providing are not valid (the protocol is missing 
in front).
When the protocol is missing, the root Url defined by the start command is 
added in front.
This is why you get "http://www.google.com/www.amazon.com" in the address.

Try these Urls instead:
 https://www.facebook.com
 https://www.yahoo.com
 https://www.google.com
 https://www.amazon.com

Or add the protocol before calling the open command:
 Dim r
 For Each r In Range(Sheet1.Cells(2, 1), Sheet1.Cells(2, 1).End(xlDown))
    selenium.executeScript "window.open()"
    selenium.Open "https://" & r
 Next r

Original comment by florentbr on 10 Jan 2015 at 2:56

  • Changed state: Done

@GoogleCodeExporter
Copy link
Author

Hi florentbr

Thank you for your reply.

I tried using firefox and it managed to open 3 tabs instead of 4 tabs. I 
noticed that the 2nd tab first's address is yahoo then it changes to google. it 
is kind of weird. (Please refer to the attached screenshot, firefox.png)

As for chrome, it opens up 4 tabs. first tab is amazon because it went through 
all the URLs on the same tab.  (Please refer to the attached screenshot, 
chrome.png)

Thanks for the insight!

Original comment by jonkh...@gmail.com on 10 Jan 2015 at 3:20

Attachments:

@GoogleCodeExporter
Copy link
Author

You need to set the window on which the driver will operate before opening the 
Url:
 wd.executeScript "window.open()"
 wd.switchToWindow -1   'Switch to the last window
 wd.Open ...

Original comment by florentbr on 10 Jan 2015 at 3:51

@GoogleCodeExporter
Copy link
Author

Hey florentbr

Thank you for the help!

The line, 'wd.switchToWindow -1' helps to ensure that each website is opened in 
each tab for chrome. (Please refer to the attached screenshot, chrome2.png)

However, it does not work for firefox unless I used this 
'selenium.executeScript "window.open()"' instead of this code, ' 
selenium.SendKeys keys.Control & "t"'  which opens up the 3 tabs instead of 4 
tabs. Also, 2nd tab first's address is yahoo then it changes to google.

Hopefully this thread will be useful for someone who want to work on firefox 
later since it works for chrome browser.

Once again florentbr.

This will be good: 
http://selenium.googlecode.com/svn-history/r5810/webdriver/javadoc/org/openqa/se
lenium/remote/server/handler/SwitchToWindow.html

Thank you for the help.

Original comment by jonkh...@gmail.com on 11 Jan 2015 at 12:07

Attachments:

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

No branches or pull requests

1 participant