| 제목 | php 셀레니움 설치 해보신분 있나요?? | ||
|---|---|---|---|
| 카테고리 | PHP | ||
| 글쓴이 | 미니미 | 작성시각 | 2021/01/17 22:11:27 |
|
|
|||
|
php 셀레니움을 설치 해보려 하는데 오류 아닌 오류가 발생 하여 고수님들의 도움을 얻고자 합니다!
설치는 https://github.com/php-webdriver/php-webdriver 여기를 참고 했고
이게 샘플로 주는 소스인데 이대로 적용을 하였습니다.
// This is where Selenium server 2/3 listens by default. For Selenium 4, Chromedriver or Geckodriver, use http://localhost:4444/
$host = 'http://localhost:4444/wd/hub';
$capabilities = DesiredCapabilities::chrome();
$driver = RemoteWebDriver::create($host, $capabilities);
// navigate to Selenium page on Wikipedia
$driver->get('https://en.wikipedia.org/wiki/Selenium_(software)');
// write 'PHP' in the search box
$driver->findElement(WebDriverBy::id('searchInput')) // find search input element
->sendKeys('PHP') // fill the search box
->submit(); // submit the whole form
// wait until 'PHP' is shown in the page heading element
$driver->wait()->until(
WebDriverExpectedCondition::elementTextContains(WebDriverBy::id('firstHeading'), 'PHP')
);
// print title of the current page to output
echo "The title is '" . $driver->getTitle() . "'\n";
// print URL of current page to output
echo "The current URL is '" . $driver->getCurrentURL() . "'\n";
// find element of 'History' item in menu
$historyButton = $driver->findElement(
WebDriverBy::cssSelector('#ca-history a')
);
// read text of the element and print it to output
echo "About to click to button with text: '" . $historyButton->getText() . "'\n";
// click the element to navigate to revision history page
$historyButton->click();
// wait until the target page is loaded
$driver->wait()->until(
WebDriverExpectedCondition::titleContains('Revision history')
);
// print the title of the current page
echo "The title is '" . $driver->getTitle() . "'\n";
// print the URI of the current page
echo "The current URI is '" . $driver->getCurrentURL() . "'\n";
// delete all cookies
$driver->manage()->deleteAllCookies();
// add new cookie
$cookie = new Cookie('cookie_set_by_selenium', 'cookie_value');
$driver->manage()->addCookie($cookie);
// dump current cookies to output
$cookies = $driver->manage()->getCookies();
print_r($cookies);
// close the browser
$driver->quit();
그런데 저 샘플을 적용시 이런 오류가 발생 하더라구요....;;;; 구글링을 해봐도 안나오고.... 내용을 봤을때에는 localhost 에 문제인거 같은데 이거 경험해 보신분 있나요??
|
|||
| 다음글 | 다운로드 헬퍼 통해서 파일 다운로드 시, 사파리의 경우... (6) | ||
| 이전글 | Mysql결과 출력하기 (3) | ||
|
한대승(불의회상)
/
2021/01/18 14:31:37 /
추천
0
설치해 본적은 없지만 오류 메시지만 놓고 봤을때 4444 포트로 접속이 안되는 거니, 셀레니움 서버가 실행되고 있는지 부터 확인해 보셔야 할 것 같습니다.
|