S
S
sfinks72021-07-21 11:26:15
PHP
sfinks7, 2021-07-21 11:26:15

How to get javascript code from html page using xpath in php selenium?

Installed selenium and phpwebriver. Next
, it turns out to find buttons and click on them, enter authorization data and other
$driver->findElement(
WebDriverBy::XPath("//button[contains(.,'Not now')]"

) javascript to extract the data of the array that is in it and work further.Here
is an example of a script.

<script type="text/javascript">window._sharedData = {"config":{"csrf_token":"vtM7sTGpo88terBmDtRp6MEMeFUEDOP3","viewer":{"video_view_count":70923б, и дальше много чего ;</script>


Tried XPath("//*[@name='video_view_count']")
and XPath("//text/javascript[@name='window._sharedData']") It says
error no such element: Unable to locate element:
In Google XPath help is not written in Javascript.
javascript is inside css tags. Maybe this is the case.

<link rel="stylesheet" href="/static/bundles/es6/ConsumerUICommons.css/22bdac298a9e.css" type="text/css" crossorigin="anonymous" />
<link rel="stylesheet" href="/static/bundles/es6/Consumer.css/4f1dc2dd323d.css" type="text/css" crossorigin="anonymous" />

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2021-07-21
@ThunderCat

XPath("//text/ javascript ")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question