首页 > 解决方案 > 我正在尝试在 selenium 中制作一个 BOT,它将打开谷歌教室并打开会议,但是

问题描述

我正在尝试在 selenium 中制作一个 BOT,它将打开 google 教室并打开会议,但问题是一切正常,只是它没有关闭 google meet 上的相机,我是 selenium 的新手,所以请帮助我出去

我的代码:

cameraOff = WebDriverWait(driver,30).until(
    EC.presence_of_element_located((By.CLASS_NAME,"U26fgb"))
)
cameraOff.click()

是的,我正确导入了所有内容,所以没有导入问题,我只想打开相机。

截屏: 这是截图

检查 HTML 代码: 检查 HTML 代码

检查 HTML 的文本代码:

<div jsshadow="" role="button" class="U26fgb JRY2Pb mUbCce kpROve uJNmj QmxbVb FTMc0c N2RpBe jY9Dbb M9Bg4d" jscontroller="lCGUBd" jsaction="click:cOuCgd; mousedown:UX7yZ; mouseup:lbsD7e; mouseenter:tfO1Yc; mouseleave:JywGue; focus:AHmuwe; blur:O22p3e; contextmenu:mg9Pef;touchstart:p6p2H; touchmove:FwuNnf; touchend:yfqBxc(preventMouseEvents=true|preventDefault=true); touchcancel:JMtRjd" jsname="BOHaEe" aria-disabled="false" tabindex="0" data-response-delay-ms="250" data-tooltip-position="top" data-tooltip-vertical-offset="12" aria-label="Turn on camera (ctrl + e)" data-tooltip="Turn on camera (ctrl + e)" data-is-muted="true"><div class="I5fjHe wb61gb"></div><div class="VTBa7b MbhUzd" jsname="ksKsZd" style="top: 26px; left: -59.5px; width: 54px; height: 54px;"></div><span jsslot=""><span class="DPvwYc JnDFsc dMzo5" aria-hidden="true"><div jscontroller="WaSQmd" jsaction="M8Qplc:BE5wSe;sO4MKe:Z1hKWc" aria-hidden="true" data-icon-type="1" class="IYwVEf nAZzG"><div class="oTVIqe BcUQQ" jsname="qmYRK" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48" preserveAspectRatio="xMidYMid meet" style="width: 100%; height: 100%;"><defs><clipPath id="animationMask_ps9OVEcY4t"><rect width="48" height="48" x="0" y="0"></rect></clipPath><mask id="RJypApJvUC"><rect fill="#ffffff" width="48" height="48" x="-24" y="-24"></rect><path fill="#000000" clip-rule="nonzero" d=" M-7.77,-10.599 C-7.77,-10.599 -9.19,-9.189 -9.19,-9.189 C-9.19,-9.189 9.2,9.201 9.2,9.201 C9.2,9.201 10.61,7.791 10.61,7.791 C10.61,7.791 -7.77,-10.599 -7.77,-10.599" fill-opacity="1"></path></mask></defs><g clip-path="url(#animationMask_ps9OVEcY4t)"><g mask="url(#RJypApJvUC)" transform="matrix(1.35,0,0,1.35,24,24)" opacity="1" style="user-select: none;"><g opacity="1" transform="matrix(1,0,0,1,0,0)"><g opacity="1" transform="matrix(1,0,0,1,0,0)"><path class="fill bkbMM" fill="rgb(255,255,255)" fill-opacity="1" d="M0 0 M-9.19,-9.189 C-9.19,-9.189 -10.61,-7.779 -10.61,-7.779 C-10.61,-7.779 7.78,10.611 7.78,10.611 C7.78,10.611 9.19,9.201 9.19,9.201 C9.19,9.201 -9.19,-9.189 -9.19,-9.189z"></path></g><g opacity="1" transform="matrix(1,0,0,1,0,0)"><path class="fill bkbMM" fill="rgb(255,255,255)" fill-opacity="1" d="M0 0 M4,-2.31 C4,-2.31 4,6 4,6 C4,6 -8,6 -8,6 C-8,6 -8,-6 -8,-6 C-8,-6 4,-6 4,-6 C4,-6 4,-2.31 4,-2.31zM0 0 M6,-1.52 C6,-1.52 6,-6 6,-6 C6,-7.1 5.1,-8 4,-8 C4,-8 -8,-8 -8,-8 C-9.1,-8 -10,-7.1 -10,-6 C-10,-6 -10,6 -10,6 C-10,7.1 -9.1,8 -8,8 C-8,8 4,8 4,8 C5.1,8 6,7.1 6,6 C6,6 6,1.52 6,1.52 C6,1.52 10,5.5 10,5.5 C10,5.5 10,-5.5 10,-5.5 C10,-5.5 6,-1.52 6,-1.52z"></path></g></g></g></g></svg></div><span class="DPvwYc cR8Azd bkl1qf" aria-hidden="true"><svg focusable="false" width="24" height="24" viewBox="0 0 24 24" class="Hdh4hc cIGbvc NMm5M"><path d="M18 10.48V6c0-1.1-.9-2-2-2H6.83l2 2H16v7.17l2 2v-1.65l4 3.98v-11l-4 3.98zM16 16L6 6 4 4 2.81 2.81 1.39 4.22l.85.85C2.09 5.35 2 5.66 2 6v12c0 1.1.9 2 2 2h12c.34 0 .65-.09.93-.24l2.85 2.85 1.41-1.41L18 18l-2-2zM4 18V6.83L15.17 18H4z"></path></svg></span><span class="DPvwYc zYrqtc thO1y" aria-hidden="true"><svg focusable="false" width="24" height="24" viewBox="0 0 24 24" class="Hdh4hc cIGbvc NMm5M"><path d="M18 10.48V6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-4.48l4 3.98v-11l-4 3.98zm-2-.79V18H4V6h12v3.69z"></path></svg></span></div></span></span></div>

其实我对css选择器不太了解,所以请帮帮我

每个答案将不胜感激,在此先感谢

标签: pythonhtmlselenium

解决方案


使用动作链

例如:

ActionChains(driver).key_down(Keys.CONTROL).send_keys('e').key_up(Keys.CONTROL).perform()

这将像按下一样工作Ctrl+e,它将关闭相机

参考:https ://selenium-python.readthedocs.io/api.html#selenium.webdriver.common.action_chains.ActionChains.key_down


推荐阅读