i can't open any link from vs code by webdriver_manager.chrome module with ChromeDriverManager class

95 Views Asked by At
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

# here my google chrome doesn't open the entered url from user
browser = webdriver.Chrome(ChromeDriverManager().install())
# browser.get(theEnterUrl)
browser.get(f"{theEnterUrl}")

when I run my code this result: enter image description here

I tried to download google chrome drivers but this will happen: enter image description here

I hope anyone helps me also I am sorry cause my English is disgusting

2

There are 2 best solutions below

0
On

You may try using the Service() class along with ChromeDriverManager().install()

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service

browser = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
browser.get("Url")
0
On

In Selenium + Java used below code working well.

package seleniump;

import java.time.Duration;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import io.github.bonigarcia.wdm.WebDriverManager;

public class Lecture10 {

    public static void main(String[] args) {
        // Locators regular expression
        
        WebDriverManager.firefoxdriver().setup();
        
         WebDriver driver = new FirefoxDriver();
         driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
         driver.manage().window().maximize();
         driver.get("https://rahulshettyacademy.com/locatorspractice/"); 
         
        ;
        driver.findElement(By.cssSelector("#inputUsername")).sendKeys("rahul");
         
         
        /*Css selctor using reguler expression
         * <input type="password" placeholder="Password" name="inputPassword" value="">
         * input[type*='passw'] //need to place only star
         */
         
         driver.findElement(By.cssSelector("input[type*='passw']")).sendKeys("rahulshettyacademy");
         
         driver.findElement(By.id("chkboxOne")).click();
         
         /*Xpath regular expression
          * 
          * <button class="submit signInBtn" type="submit">Sign In</button>
          * 
          * //button[contains(@class,'submit')]  //Regular expression of above Login button.
          */
         
         driver.findElement(By.xpath("//button[contains(@class,'submit')]")).click();
         
         driver.close();
         
         

    }

}