使用geckodriver打开浏览器时无法编辑嵌入式Google日历
问题描述:
因此,我为我的CPS类制作了魔术镜,并且我做了它,因此它将在全屏模式下使用浏览器选项卡进行多个显示。对于其中一台显示器,我希望将嵌入式Google日历调整为适合我的27英寸显示器(Google提供的日历设置)。当我在Firefox中正常打开日历时,该日历正常工作,但是当使用硒进行Geckodriver打开Firefox时,日历显示,但处于通用状态,无法对其进行编辑。我试图在其他浏览器中打开.html页面,它们都可以工作。这就是它的样子: GeckoDriver Display,FireFox Display。 该日历涉及使用iframe标记,我试图改变为具有相同结果的对象标记。下面是IFRAME代码:使用geckodriver打开浏览器时无法编辑嵌入式Google日历
<iframe src="https://calendar.google.com/calendar/embed?showTitle=0&showDate=0&showPrint=0&showTabs=0&
showCalendars=0&height=1810&wkst=1&bgcolor=%23000000&src=tvanderlinden8%40gmail.com&color=%2329527A&
src=%23contacts%40group.v.calendar.google.com&color=%2329527A&src=en.usa%23holiday%40group.v.calendar.google.com&
color=%2329527A&ctz=America%2FNew_York" style="border-width:0"width="1000" height="1800" frameborder="0" scrolling="no"></iframe>
随着我的Python打开每个HTML文件:
# Imports
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
# Create new browser and open all display tabs
# Open Firefox dir
driver = webdriver.Firefox()
# Open google tab
driver.get('http://google.com')
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
# Open MagicMirror.html, MagicMirror2.html, and MagicMirror3.html (all 3 displays)
driver.get('/home/pi/Desktop/MagicMirror/MagicMirror.html')
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
driver.get('/home/pi/Desktop/MagicMirror/MagicMirror2.html')
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
driver.get('/home/pi/Desktop/MagicMirror/MagicMirror3.html')
# Close google tab
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + Keys.TAB)
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 'w')
# Set webpage to full screen
driver.find_element_by_tag_name('body').send_keys(Keys.F11)
# Variable used to determine if display is showing 1st or 3rd display
disNum = 1
# Input to change display
while(True):
display = int(input("Please select a display: "))
# Moves right a display unless it is at the last display
if (display == 1 and disNum != 3):
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + Keys.TAB)
disNum += 1
# Moves left a display unless it is at the first display
if (display == 2 and disNum != 1):
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + Keys.SHIFT + Keys.TAB)
disNum -= 1
没有错误,因为它在某种程度上的“工作”。它只是不按我需要的方式工作。
答
我想出了一个完美的解决方案。
<object data="https://calendar.google.com/calendar/embed?showTitle=0&showNav=0&
showDate=0&showPrint=0&showTabs=0&showCalendars=0&showTz=0&height=1400&
wkst=1&bgcolor=%23000000&src=tvanderlinden8%40gmail.com&color=%2329527A&
data=%23contacts%40group.v.calendar.google.com&color=%2329527A&
src=en.usa%23holiday%40group.v.calendar.google.com&color=%2329527A&
ctz=America%2FNew_York" style="border-width:0" width="1000" height="1820"></object>
你想改变这一切“SRC对‘数据’,但我发现,如果你只改变开始和%23contacts%......到‘数据’解决了这个问题。确保您已经登录到您的Google帐户,以便它可以检索您的日历数据。
请参阅:[我如何做X?](https://meta.*.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-doi-i- do-x)对SO的期望是用户提出问题不仅仅是研究来回答他们自己的问题,而且还分享研究,代码尝试和结果。这表明你已经花时间去尝试帮助自己,它使我们避免重申明显的答案,最重要的是它可以帮助你得到更具体和相关的答案!另请参阅:[问] – JeffC
您可以分享您的代码试用版,错误堆栈跟踪和HTML吗? – DebanjanB