无法单击/选择Selenium中的广播按钮
我正在尝试从'https://www.velocityap.com/product/3-0l-v6-supercharged--jaguar-land-land-land-rover-aj126-ecu-tuning/'网站刮下来。为此,需要单击的一组广播按钮选项以揭示汽车零件的价格(下图中的红色标记)需要刮擦。
我为实现这一目标而编写的代码如下:
options_panel_4 = driver.find_elements(By.CSS_SELECTOR,'div.summary.entry-summary > div.mspc-wrapper.mspc-clearfix.mspc-module-accordion.mspc-auto-next.mspc-step-by-step > div > div:nth-child(8) > div > div')
print('Options under options panel 3 :', len(options_panel_4))
for option_4 in options_panel_4:
driver.execute_script("arguments[0].scrollIntoView();", option_4)
option_4.find_element(By.CSS_SELECTOR, 'div > div.mspc-radio.ui.radio.checkbox > input[type=radio]').click()
但是,它引发了例外,如下:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <div class="mspc-radio ui radio checkbox">...</div> is not clickable at point (890, 14). Other element would receive the click: <div class="infinite-navigation infinite-item-pdlr clearfix infinite-navigation-submenu-indicator ">...</div>
(Session info: chrome=102.0.5005.115)
Stacktrace:
0 chromedriver 0x00000001024162c9 chromedriver + 5120713
1 chromedriver 0x00000001023a4e33 chromedriver + 4656691
2 chromedriver 0x0000000101f94158 chromedriver + 393560
3 chromedriver 0x0000000101fd0638 chromedriver + 640568
4 chromedriver 0x0000000101fce1b3 chromedriver + 631219
5 chromedriver 0x0000000101fcb814 chromedriver + 620564
6 chromedriver 0x0000000101fca5b2 chromedriver + 615858
7 chromedriver 0x0000000101fbe249 chromedriver + 565833
8 chromedriver 0x0000000101fe6482 chromedriver + 730242
9 chromedriver 0x0000000101fbdb05 chromedriver + 563973
10 chromedriver 0x0000000101fe658e chromedriver + 730510
11 chromedriver 0x0000000101ff8f41 chromedriver + 806721
12 chromedriver 0x0000000101fe6373 chromedriver + 729971
13 chromedriver 0x0000000101fbc609 chromedriver + 558601
14 chromedriver 0x0000000101fbd635 chromedriver + 562741
15 chromedriver 0x00000001023e8b1d chromedriver + 4934429
16 chromedriver 0x00000001023ed295 chromedriver + 4952725
17 chromedriver 0x00000001023f23cf chromedriver + 4973519
18 chromedriver 0x00000001023edcba chromedriver + 4955322
19 chromedriver 0x00000001023c837c chromedriver + 4801404
20 chromedriver 0x0000000102407c68 chromedriver + 5061736
21 chromedriver 0x0000000102407def chromedriver + 5062127
22 chromedriver 0x000000010241d5e5 chromedriver + 5150181
23 libsystem_pthread.dylib 0x00007ff80f3874e1 _pthread_start + 125
24 libsystem_pthread.dylib 0x00007ff80f382f6b thread_start + 15
I am trying scrape data out of 'https://www.velocityap.com/product/3-0l-v6-supercharged-jaguar-land-rover-aj126-ecu-tuning/' website. For which, set of radio button options need to clicked to reveal price for the car part(price marked in red in picture below) which needs to scraped.
Code I've written to achieve that is as follows:
options_panel_4 = driver.find_elements(By.CSS_SELECTOR,'div.summary.entry-summary > div.mspc-wrapper.mspc-clearfix.mspc-module-accordion.mspc-auto-next.mspc-step-by-step > div > div:nth-child(8) > div > div')
print('Options under options panel 3 :', len(options_panel_4))
for option_4 in options_panel_4:
driver.execute_script("arguments[0].scrollIntoView();", option_4)
option_4.find_element(By.CSS_SELECTOR, 'div > div.mspc-radio.ui.radio.checkbox > input[type=radio]').click()
However, It throws exception as follows:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <div class="mspc-radio ui radio checkbox">...</div> is not clickable at point (890, 14). Other element would receive the click: <div class="infinite-navigation infinite-item-pdlr clearfix infinite-navigation-submenu-indicator ">...</div>
(Session info: chrome=102.0.5005.115)
Stacktrace:
0 chromedriver 0x00000001024162c9 chromedriver + 5120713
1 chromedriver 0x00000001023a4e33 chromedriver + 4656691
2 chromedriver 0x0000000101f94158 chromedriver + 393560
3 chromedriver 0x0000000101fd0638 chromedriver + 640568
4 chromedriver 0x0000000101fce1b3 chromedriver + 631219
5 chromedriver 0x0000000101fcb814 chromedriver + 620564
6 chromedriver 0x0000000101fca5b2 chromedriver + 615858
7 chromedriver 0x0000000101fbe249 chromedriver + 565833
8 chromedriver 0x0000000101fe6482 chromedriver + 730242
9 chromedriver 0x0000000101fbdb05 chromedriver + 563973
10 chromedriver 0x0000000101fe658e chromedriver + 730510
11 chromedriver 0x0000000101ff8f41 chromedriver + 806721
12 chromedriver 0x0000000101fe6373 chromedriver + 729971
13 chromedriver 0x0000000101fbc609 chromedriver + 558601
14 chromedriver 0x0000000101fbd635 chromedriver + 562741
15 chromedriver 0x00000001023e8b1d chromedriver + 4934429
16 chromedriver 0x00000001023ed295 chromedriver + 4952725
17 chromedriver 0x00000001023f23cf chromedriver + 4973519
18 chromedriver 0x00000001023edcba chromedriver + 4955322
19 chromedriver 0x00000001023c837c chromedriver + 4801404
20 chromedriver 0x0000000102407c68 chromedriver + 5061736
21 chromedriver 0x0000000102407def chromedriver + 5062127
22 chromedriver 0x000000010241d5e5 chromedriver + 5150181
23 libsystem_pthread.dylib 0x00007ff80f3874e1 _pthread_start + 125
24 libsystem_pthread.dylib 0x00007ff80f382f6b thread_start + 15
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
错误代码告诉您的是,问题是当您向下滚动时,顶部菜单涵盖了无线电输入。因此,如果在哪里单击它,它不会单击收音机,它将单击菜单。
另外,它不允许您选择收音机本身,而是选择某个DIV,这是该/html/body/div [3]/div/div/div [4]/div [2]/div/div/div/div/div的xpath [2]/div [2]/div [2]/div/div/div [4]/div/div/div [2]
我快速尝试,手动滚动并手动选择先前的广播按钮,然后正确选择了最后一个人会在遇到问题的地方,以下是代码:
我使用XPATH,因为我预先使用它,这并不意味着您也必须这样做。
我还添加了一个时间等待它等待加载,还让我选择以前的收音机按钮
What the error code is telling you is that the problem is when you scroll down, the top menu is covering the radio input. So, if it where to click on it, it would't click the radio it'd click the menu.
Also it doesn't let you select the radio itself, you hafe to select a certain div, here's the xpath to that /html/body/div[3]/div/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[4]/div/div[2]
I made a quick try, scrolling manually and selecting the previous radio buttons manually as well, and it selected correctly the last one wich you where having problems with, here's the code:
I use xpath because i prefere it, it does not mean you also have to.
I also added a time wait for it to wait for loading and also for me to chose the previous radio buttons
由于您想获取有关所有产品的数据,因此我将获得复选框的所有XPATH,例如'// input [ @type =“ radio”和 @value =“ Jaguar-f-type-type-type-type-f-pace-xe-xe-xe-xf -xj“]'。当我将拥有所有Xpath时,我将执行一个脚本来选择所有选项,并且我将完成此xPath'//*[@class =“ price”]/descendant :: span [@class =“ woocommerce--价格昂贵的金额”]'
As you want to get datas about all products, so I would get all xpaths of checkboxes, for example '//input[@type="radio" and @value="jaguar-f-type-f-pace-xe-xf-xj"]'. When I will have all xpaths, I will do a script to select all options and I will finish get the text of this xpath '//*[@class="price"]/descendant::span[@class="woocommerce-Price-amount amount"]'