Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript python selenium爬行无法定位元素错误_Javascript_Python_Selenium_Css Selectors_Web Crawler - Fatal编程技术网

Javascript python selenium爬行无法定位元素错误

Javascript python selenium爬行无法定位元素错误,javascript,python,selenium,css-selectors,web-crawler,Javascript,Python,Selenium,Css Selectors,Web Crawler,我正在研究selenium的web爬行,发现了一些错误 这是我的编码如下 from selenium import webdriver as wd main_url = 'https://searchad.naver.com/' driver = wd.Chrome(executable_path='chromedriver.exe') 我登录了 # access main url2 main_url2 = 'https://searchad.naver.com/my-screen' #

我正在研究selenium的web爬行,发现了一些错误

这是我的编码如下

from selenium import webdriver as wd
main_url = 'https://searchad.naver.com/'
driver = wd.Chrome(executable_path='chromedriver.exe')
我登录了

# access main url2

main_url2 = 'https://searchad.naver.com/my-screen'

# close popup window
driver.find_element_by_css_selector('body > my-app > wrap > welcome-beginner-layer-popup > div.ly_main_pop > div.pop_top > a').click() 

# main3 page access
driver.find_element_by_css_selector('.btn_area>li').click()

# click tool menu bar
driver.find_element_by_css_selector('#navbar-common-header-collapse > ul > li:nth-child(3) > a > span.ng-binding.ng-scope').click()
从上一次编码(#单击工具菜单栏)中,出现如下错误: 错误消息:

消息:没有这样的元素:无法找到元素。 Css选择器和xpath都是错误

这是我单击鼠标之前的参考资料代码'도구' 具体如下

<a class="dropdown-toggle ng-scope" ng-if="menu.items" href="" data-toggle="dropdown" role="button" aria-expanded="false"><!-- ngIf: menu.gnb != "billing" --><span ng-if="menu.gnb != &quot;billing&quot;" ng-bind-html="menu.translationId | translate" class="ng-binding ng-scope">도구</span><!-- end ngIf: menu.gnb != "billing" --><!-- ngIf: menu.gnb === "billing" --><span class="ico-dropdown-arrow"></span></a>

<!-- ngIf: menu.gnb != "billing" -->

<span ng-if="menu.gnb != &quot;billing&quot;" ng-bind-html="menu.translationId | translate" class="ng-binding ng-scope">도구</span> 

도구 
在我点击菜单的도구', 我可以找到'키워드 도구'. 这也是我们的代码키워드도구'.

<li ng-repeat="submenu in menu.items track by $index" ng-class="{ divider: submenu === &quot;divider&quot;, disabled: submenu.disabled }" class="ng-scope"><!-- ngIf: submenu.disabled --><!-- ngIf: submenu !== "divider" && !submenu.disabled --><a ng-if="submenu !== &quot;divider&quot; &amp;&amp; !submenu.disabled" data-click-logger="" data-click-id="click.tool.keyword-planner" href="/customers/668860/tool/keyword-planner" ui-sref="tool.keyword-planner(vm.getParams({customerId: customerId}, submenu.params))" ui-sref-opts="{reload: submenu.reload}" ng-bind-html="submenu.translationId | translate" class="ng-binding ng-scope">키워드 도구</a><!-- end ngIf: submenu !== "divider" && !submenu.disabled --></li>
<!-- ngIf: submenu.disabled -->
<!-- ngIf: submenu !== "divider" && !submenu.disabled -->
<a ng-if="submenu !== &quot;divider&quot; &amp;&amp; !submenu.disabled" data-click-logger="" data-click-id="click.tool.keyword-planner" href="/customers/668860/tool/keyword-planner" ui-sref="tool.keyword-planner(vm.getParams({customerId: customerId}, submenu.params))" ui-sref-opts="{reload: submenu.reload}" ng-bind-html="submenu.translationId | translate" class="ng-binding ng-scope">키워드 도구</a>

  • Selenium有几个函数等待元素加载。 了解selenium.webdriver.support.expected\u条件

    默认情况下,预期条件等待大约30秒,元素才会显示在页面上。如果你在网站上点击的话,这是非常有用的


    有一个很好的例子。

    我做了time.sleep(30),但是结果有相同的错误。谢谢你的评论。你把睡眠放在哪里了?另外,请确保您将鼠标悬停在菜单选项卡上,而不是单击它。谢谢您的评论。我不知道hover和Actionchain,所以我需要研究一下这个领域。。请读一读为什么会这样。考虑用格式化的基于文本的相关HTML、代码试验和错误堆栈跟踪更新问题。我不知道这不是显示HTML或代码的好方法。所以我复制代码。谢谢你的评论。