问题
I've been trying to insert an image to a google slide but I can only the dropdown icon and not the menu items. The google slides HTML portion of the menu looks like this.
<div class="goog-menuitem apps-menuitem" role="menuitem" id="955fby:sw" style="user-select: none;">
<div class="goog-menuitem-content" style="user-select: none;">
<div class="docs-icon goog-inline-block goog-menuitem-icon" aria-hidden="true" style="user-select: none;">
<div class="docs-icon-img-container docs-icon-img docs-icon-file-upload" style="user-select: none;"></div>
</div>
<span class="goog-menuitem-label" style="user-select: none;">Upload from computer</span>
</div>
</div>
I couldn't go further on the dropdown menu. I can't click the menu items by using XPath, class name, id, CSS.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
options = Options()
options.add_argument("start-maximized")
options.add_argument("user-data-dir=C:\\Users\\praba\\AppData\\Local\\Google\\Chrome\\User Data\\")
driver = webdriver.Chrome(executable_path=r'chromedriver',options=options)
time.sleep(5)
driver.get("https://docs.google.com/presentation/u/0/create?usp=slides_web")
time.sleep(5)
driver.find_element_by_id('insertImageMenuButton').click()
来源:https://stackoverflow.com/questions/62300818/how-to-insert-an-image-using-selenium-in-google-slides