stuck on get() method

194 views
Skip to first unread message

RRRR

unread,
Aug 10, 2016, 12:56:24 AM8/10/16
to Selenium Users
Few days ago I was doing practical exercises and my Fairfox browser was opening fine and everything afterwards got executed. However, today I am unable to open the url specified in a script. No changes at all were made to the script, but I still get a message that a url can't be opened. I even tried updating my browser to the latest version, but even after that the specified url was not opening. What could be the reason, if it was working few days ago, but not working now?

⇜Krishnan Mahadevan⇝

unread,
Aug 10, 2016, 1:13:07 AM8/10/16
to Selenium Users
Short answer : No idea. 

We don't know what URL you are using to open up, what are your internet connectivity settings etc.,

So there's not much that anyone can do here to help you out.

Have you tried opening up the URL manually and check if that works? 
If manually the URL works and only via the automation test code it doesn't then, you would need to share your code so that we can see it and confirm if there's anything that stands out as unusual.

You also could setup breakpoints right after the FirefoxDriver browser object is instantiated, and then try loading your URL manually. You can also inspect the browser settings (after it has been spun off by Selenium) and make sure if its network settings are all fine.

Lastly you could toggle to a different browser flavor and see if the problem occurs there as well.

Lots of exercises that you would need to carry out at your end, to help you narrow down on the root cause.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Wed, Aug 10, 2016 at 10:26 AM, RRRR <abr...@gmail.com> wrote:
Few days ago I was doing practical exercises and my Fairfox browser was opening fine and everything afterwards got executed. However, today I am unable to open the url specified in a script. No changes at all were made to the script, but I still get a message that a url can't be opened. I even tried updating my browser to the latest version, but even after that the specified url was not opening. What could be the reason, if it was working few days ago, but not working now?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/efebb069-2fc8-443c-83d2-8eaaa22edeb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

shruthi v v

unread,
Aug 10, 2016, 1:17:33 AM8/10/16
to seleniu...@googlegroups.com
Also kindly attach the screenshot of the error page along with your code snippet 














Shruthi

On Wed, Aug 10, 2016 at 10:42 AM, ⇜Krishnan Mahadevan⇝ <krishnan.ma...@gmail.com> wrote:
Short answer : No idea. 

We don't know what URL you are using to open up, what are your internet connectivity settings etc.,

So there's not much that anyone can do here to help you out.

Have you tried opening up the URL manually and check if that works? 
If manually the URL works and only via the automation test code it doesn't then, you would need to share your code so that we can see it and confirm if there's anything that stands out as unusual.

You also could setup breakpoints right after the FirefoxDriver browser object is instantiated, and then try loading your URL manually. You can also inspect the browser settings (after it has been spun off by Selenium) and make sure if its network settings are all fine.

Lastly you could toggle to a different browser flavor and see if the problem occurs there as well.

Lots of exercises that you would need to carry out at your end, to help you narrow down on the root cause.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
On Wed, Aug 10, 2016 at 10:26 AM, RRRR <abr...@gmail.com> wrote:
Few days ago I was doing practical exercises and my Fairfox browser was opening fine and everything afterwards got executed. However, today I am unable to open the url specified in a script. No changes at all were made to the script, but I still get a message that a url can't be opened. I even tried updating my browser to the latest version, but even after that the specified url was not opening. What could be the reason, if it was working few days ago, but not working now?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

RRRR

unread,
Aug 10, 2016, 1:26:13 AM8/10/16
to Selenium Users
Yes, I should have said that I tried opening the same URL manually and it works fine in Firefox and Chrome. What is strange is why when I run I get a message that it can't open, if few days back the same URL was opening fine with get() method. Does it help to narrow it down before I share my code?


On Wednesday, August 10, 2016 at 12:13:07 AM UTC-5, Krishnan wrote:
Short answer : No idea. 

We don't know what URL you are using to open up, what are your internet connectivity settings etc.,

So there's not much that anyone can do here to help you out.

Have you tried opening up the URL manually and check if that works? 
If manually the URL works and only via the automation test code it doesn't then, you would need to share your code so that we can see it and confirm if there's anything that stands out as unusual.

You also could setup breakpoints right after the FirefoxDriver browser object is instantiated, and then try loading your URL manually. You can also inspect the browser settings (after it has been spun off by Selenium) and make sure if its network settings are all fine.

Lastly you could toggle to a different browser flavor and see if the problem occurs there as well.

Lots of exercises that you would need to carry out at your end, to help you narrow down on the root cause.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Wed, Aug 10, 2016 at 10:26 AM, RRRR <abr...@gmail.com> wrote:
Few days ago I was doing practical exercises and my Fairfox browser was opening fine and everything afterwards got executed. However, today I am unable to open the url specified in a script. No changes at all were made to the script, but I still get a message that a url can't be opened. I even tried updating my browser to the latest version, but even after that the specified url was not opening. What could be the reason, if it was working few days ago, but not working now?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

⇜Krishnan Mahadevan⇝

unread,
Aug 10, 2016, 1:47:07 AM8/10/16
to Selenium Users
No it doesn't. Put yourself in others shoes and think. If you were to be given only this much information and asked to call out what could be the root cause of the problem, would you be able to ?

Are you in a corporate environment behind a corporate proxy ? If yes, then that could be the reason for this because when you browse manually, most often your company's IT team would have ensured that the proxy settings are set by default in your browser. But when you are trying to spin off a browser via Selenium, those proxy settings may not get applied.

What is strange is why when I run I get a message that it can't open, if few days back the same URL was opening fine with get() method. 

Well, all I can say is that Selenium cannot be at fault here because this is a very basic use case and if this was broken, then the Selenium WebDriver's unit tests themselves would have caught this.

So if you need help on getting your issue resolved, you have to provide as much context to your issue as possible. Its not helping you or others by giving out information about your environment/code etc., on a piece meal basis.!


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/4f97366c-e841-4835-8489-69dd554e1287%40googlegroups.com.

RRRR

unread,
Aug 10, 2016, 2:14:51 AM8/10/16
to Selenium Users
Hereunder is one one of the scripts that was running two days ago without a problem,  but is failing now. Also, it was done on a home computer with no networking.

import java.util.concurrent.TimeUnit;
 
import org.openqa.selenium.Alert;
 
import org.openqa.selenium.By;
 
import org.openqa.selenium.WebDriver;
 
import org.openqa.selenium.firefox.FirefoxDriver;
 
import org.openqa.selenium.support.ui.ExpectedConditions;
 
import org.openqa.selenium.support.ui.WebDriverWait;
 
public class PracticeWaitCommands {
 
public static WebDriver driver;
 
public static void main(String[] args) {
 
// Create a new instance of the Firefox driver
 
        driver = new FirefoxDriver();
 
        // Put an Implicit wait, this means that any search for elements on the page could take the time the implicit wait is set for before throwing exception
 
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
 
        // Launch the URL
 
 
        // Click on the Button "Timing Alert"
 
        driver.findElement(By.name("Timing Alert")).click();
 
        System.out.println("Timer JavaScript Alert is triggered but it is not yet opened");
 
        // Create new WebDriver wait
 
        WebDriverWait wait = new WebDriverWait(driver, 10);
 
        // Wait for Alert to be present
 
        Alert myAlert = wait.until(ExpectedConditions.alertIsPresent());
 
        System.out.println("Either Pop Up is displayed or it is Timed Out");
 
        // Accept the Alert
 
        myAlert.accept();
 
        System.out.println("Alert Accepted");
 
        // Close the main window
 
        driver.close();
 
}
 
}

This is just an exercise , but can someone try it from their end and see, if it opens up properly?

Mallik H

unread,
Aug 10, 2016, 5:21:05 AM8/10/16
to Selenium Users
Successfully executed below code:

// Create a new instance of the Firefox driver
 
        driver = new FirefoxDriver();
 
        // Put an Implicit wait, this means that any search for elements on the page could take the time the implicit wait is set for before throwing exception
 
        //driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
 
        // Launch the URL
 
 
        // Click on the Button "Timing Alert"
        driver.findElement(By.xpath("//button[text()='Timing Alert']")).click();
 
        ///System.out.println("Timer JavaScript Alert is triggered but it is not yet opened");
 
        // Create new WebDriver wait
 
        WebDriverWait wait = new WebDriverWait(driver, 10);
 
        // Wait for Alert to be present
 
        Alert myAlert = wait.until(ExpectedConditions.alertIsPresent());
 
        System.out.println("Either Pop Up is displayed or it is Timed Out");
 
        // Accept the Alert
 
        myAlert.accept();
 
        System.out.println("Alert Accepted");
 
        // Close the main window
 
        driver.close(); 

Andrew Jervis

unread,
Aug 10, 2016, 12:18:12 PM8/10/16
to Selenium Users
RRRR

The following code opens OK under Firefox 47.0.1 & Selenium 2.53.1 (This code is similar to your code with very minor changes)

It comes up with the error 'Unable to locate element: {"method":"name","selector":"Timing Alert"}' on the line

driver.findElement(By.name("Timing Alert")).click();

Trust that helps

Regards, Andrew Jervis

****************

package Trainingpack;


import java.util.concurrent.TimeUnit;

import org.openqa.selenium.Alert;
 
import org.openqa.selenium.By;
 
import org.openqa.selenium.WebDriver;
 
import org.openqa.selenium.firefox.FirefoxDriver;
 
import org.openqa.selenium.support.ui.ExpectedConditions;
 
import org.openqa.selenium.support.ui.WebDriverWait;

public class zent8 {

 
    public static WebDriver driver;
 
    public static void main(String[] args) {
 
        // Create a new instance of the Firefox driver
 
        driver = new FirefoxDriver();
 
        // Put an Implicit wait, this means that any search for elements on the page could take the time the implicit wait is set for before throwing exception
 
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
 
        // Launch the URL
 
        driver.get("http://toolsqa.com/automation-practice-switch-windows/");
 
        // Click on the Button "Timing Alert"
 
        driver.findElement(By.name("Timing Alert")).click();
 
        System.out.println("Timer JavaScript Alert is triggered but it is not yet opened");
 
        // Create new WebDriver wait
 
        WebDriverWait wait = new WebDriverWait(driver, 10);
 
        // Wait for Alert to be present
 
        Alert myAlert = (Alert) wait.until(ExpectedConditions.alertIsPresent());
Reply all
Reply to author
Forward
0 new messages