I'm using thirtyfour as a Selenium/Webdriver library.
What I want to know is how to connect the Chrome browser which is launched with debugging mode.
I tried as below:
- Launched a Chrome as debugging mode:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9000 --user-date-dir=D:\tmp_chrome
- Executed
chromedriver
:
chromedriver.exe --port=9000
- run test code:
use thirtyfour::prelude::*;
#[tokio::main]
async fn main() -> WebDriverResult<()> {
let caps = DesiredCapabilities::chrome();
let driver = WebDriver::new("http://localhost:9000", caps).await?;
// Navigate to https://wikipedia.org.
driver.goto("https://wikipedia.org").await?;
let elem_form = driver.find(By::Id("search-form")).await?;
// Find element from element.
let elem_text = elem_form.find(By::Id("searchInput")).await?;
// Type in the search terms.
elem_text.send_keys("selenium").await?;
// Click the search button.
let elem_button = elem_form.find(By::Css("button[type='submit']")).await?;
elem_button.click().await?;
// Look for header to implicitly wait for the page to load.
driver.find(By::ClassName("firstHeading")).await?;
assert_eq!(driver.title().await?, "Selenium - Wikipedia");
// explicitly close the browser.
driver.quit().await?;
Ok(())
}
The result is:
- A new Chrome browser is launched newly and loaded wikipedia page.
What I want is the web page is viewed in the existing Chrome browser which is launched in the first step.
Could anyone guide me how can I use already existing Chrome browser using thirtyfour library?