Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
534 views
by Contributing Tester (22 points)
edited by
I tried to run below selenium script and not able to open chrome browser to run the all listed operations:

package automationFramework;

import org.openqa.selenium.chrome.ChromeDriver;

import appModule.Add_Cart;

public class Test {

public static ChromeDriver driver= null;

public static void main(String[] args) throws Exception {

// TODO Auto-generated method stub

String exepath= "C:\\SamtaSelenium\\Chromedriver\\chromedriver.exe";

System.setProperty("webdriver.chrome.driver", exepath);

                System.setProperty("java.net.preferIPv4Stack" , "true");

driver= new ChromeDriver();

driver.get("http://automationpractice.com/index.php");

Thread.sleep(5000);

    

// Maximize the Browser Window

    driver.manage().window().maximize();

    

    //Add item in the cart

    Add_Cart.Mouse_Hover(driver);

    

//SignIn_Action.Login(driver);

Thread.sleep(300);

}

}

When I Run above script then getting below output in the console. after internet surfing, I have added command System.setProperty("java.net.preferIPv4Stack" , "true"); as requested on internet and after that also i am getting same result.

lo

   address.getHostName() = 127.0.0.1

   address.getHostAddress() = 127.0.0.1

   address.isLoopbackAddress() = true

   address.getHostName() = 0:0:0:0:0:0:0:1

   address.getHostAddress() = 0:0:0:0:0:0:0:1

   address.isLoopbackAddress() = true

eth0

   address.getHostName() = fe80:0:0:0:4593:d706:294d:eb47%eth0

   address.getHostAddress() = fe80:0:0:0:4593:d706:294d:eb47%eth0

   address.isLoopbackAddress() = false

eth1

wlan0

   address.getHostName() = 192.168.1.5

   address.getHostAddress() = 192.168.1.5

   address.isLoopbackAddress() = false

   address.getHostName() = fd14:5f94:8201:a200:9c:a119:5716:9d89

   address.getHostAddress() = fd14:5f94:8201:a200:9c:a119:5716:9d89

   address.isLoopbackAddress() = false

   address.getHostName() = fd14:5f94:8201:a200:4104:f47d:cdae:6b0b

   address.getHostAddress() = fd14:5f94:8201:a200:4104:f47d:cdae:6b0b

   address.isLoopbackAddress() = false

   address.getHostName() = fe80:0:0:0:9c:a119:5716:9d89%wlan0

   address.getHostAddress() = fe80:0:0:0:9c:a119:5716:9d89%wlan0

   address.isLoopbackAddress() = false

net0

   address.getHostName() = fe80:0:0:0:0:5efe:c0a8:105%net0

   address.getHostAddress() = fe80:0:0:0:0:5efe:c0a8:105%net0

   address.isLoopbackAddress() = false

net1

wlan1

   address.getHostName() = fe80:0:0:0:6d0a:dcb8:612a:681d%wlan1

   address.getHostAddress() = fe80:0:0:0:6d0a:dcb8:612a:681d%wlan1

   address.isLoopbackAddress() = false

net2

eth2

eth3

eth4

wlan2

wlan3

wlan4

wlan5

wlan6

wlan7

wlan8

wlan9

wlan10

Loopback interface LO:

lo

   address.getHostName() = 127.0.0.1

   address.getHostAddress() = 127.0.0.1

   address.isLoopbackAddress() = true

   address.getHostName() = 0:0:0:0:0:0:0:1

   address.getHostAddress() = 0:0:0:0:0:0:0:1

   address.isLoopbackAddress() = true

Please suggest me that how can I fix this issue? I am running this for Chrome browser.

1 Answer

0 like 0 dislike
by Master (1.2k points)
It looks like your chromedriver is outdated. Have you tried updating the chromedriver?
by Contributing Tester (22 points)
I am having two scripts and one is running and another is giving this result and not opening chrome browser.
If chrome is having issue then first script should not run.
by Contributing Tester (22 points)
I am using chrome browser both scripts also
by Master (1.2k points)
okay. in that case, can you use driver.quit(); at the end of the execution?
by Contributing Tester (22 points)
Hi Mayur,

Thanks for your suggestion but still getting same issue after adding driver.quit() at the end of the script.

Just want to ask that can i use two main method script in our framework? May be this is the case that i am using two main method(public static void main(String[] args)) in two different script. But if this is the case then another script should not run successfully.
by Master (1.2k points)
Using two main methods in two different scripts should not be a problem at all.

You have posted a script that is not working, can you post a script that is working?

Also, I have few questions.
Are you executing both scripts together?
If you are executing both scripts together, are you doing it sequentially?
by Master (1.2k points)
Also, I am talking about using driver.quit on both scripts.

And also, open performance monitor and kill all chromedriver.exe. Since you are not using driver.quit, I am sure you will have so many chromedriver opened up.
by Contributing Tester (22 points)
Hi Mayur,

Thanks for your quick reply.Sorry for late reply.

I have Kill all chromedriver.exe all background process from Task manager.you are talking about performance monitor and i think i need to do this only. If i need to do something else to kill  all chromedriver.exe in performance monitor then please advice me.
Then added driver.quit command in both scripts and same result i am getting, still same issue is there. I have done copy from the first script which is successfully running, and pasting in second script in main method, But not opening chrome browser.

I am getting this type issue first time. I do not know why i am getting this issue.

This is my below script which is running properly:

package automationFramework;

import org.openqa.selenium.chrome.ChromeDriver;

import appModule.Add_Cart;
import appModule.SignIn_Action;

public class Module_TC {
    public static ChromeDriver driver= null;
    public static void main(String[] args) throws Exception {
       
        String exepath= "C:\\SamtaSelenium\\Chromedriver\\chromedriver.exe";
        System.setProperty("webdriver.chrome.driver", exepath);
       
        driver= new ChromeDriver();
       
        driver.get("http://automationpractice.com/index.php");
        Thread.sleep(5000);
        
        // Maximize the Browser Window
        driver.manage().window().maximize();
        
        //Add item in cart
        Add_Cart.Mouse_Hover(driver);
        
        //SignIn_Action.Login(driver);
       
        Thread.sleep(300);
       
        //Login to web site with existing user
        //SignIn_Action.Login_User(driver);
       
        // Element present on page
        //SignIn_Action.IsDisplay(driver);
       
        driver.quit();
       
       

    }

}
by Contributing Tester (22 points)
Hi Mayur,

Thanks to Resolve this issue that i need to save(Ctr+S) scripts before run the script.

thanks for help and time.

Really good website to work on selenium.

Regards
Samta


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...