I'm hoping someone can help me understand a bit better so the site I've been referencing up to this point is https://selenium-python.readthedocs.io/locating-elements.html#locating-elements-by-css-selectors
This is the code (It does work)
#https://www.softwaretestinghelp.com/selenium-python-tutorial/#Configuration_Of_Selenium_In_PyCharm
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
serv = Service(r"C:\Users\BAtMAn\PycharmProjects\DellUpdate\Drivers\chromedriver.exe")
driver = webdriver.Chrome(service=serv)
driver.get("https://www.dell.com/support")
driver.maximize_window()
def Step1():
SearchBar = driver.find_element(By.NAME, "entry-main-input-home").send_keys("Test")
SearchBarClick = driver.find_element(By.ID,"txtSearchEs").click()
Step1()
def Popup():
if driver.find_element(By.ID, "sec-overlay"):
time.sleep(30.5)
SearchBarClick = driver.find_element(By.ID, "txtSearchEs").click()
time.sleep(5)
Popup()
def FeedBack():
if driver.find_element(By.CSS_SELECTOR, ('<button id="noButtonIPDell" class="noButton buttons" aria-label="No, thanks">No, thanks</button>)'):
driver.find_element(By.ID, "button id#noButtonIPDell").click()
FeedBack()
def Drivers():
if FeedBack() == False:
driver.find_element(By.ID, "drivers").click()
Drivers()
My issue is I went through a bunch of ID and Class_NAMEs before finding one that works and I'm wondering if it's I just don't understand what I'm reading yet. Below is a list of the class_name and ID's I attempted but driver.find_element didn't locate anything.
CLASS_NAME, ""): custom-Aka-popup-body-area aka-popup-text-center aka-popup-margin-bottom24 custom-Aka-popup-icon
ID es-alert-notice-duotone sec-overlay
Okay so what I was inspecting was the 30 second delay popup that I kept getting from dell.com/support The pop up only seems to appear when running the code not when I manually pull everything up.
(Most current version 8/24 3pm gmt-4) Error(does not click the "Find Drivers drop down")
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//iframe[@title='Dell Survey']"}
# https://www.softwaretestinghelp.com/selenium-python-tutorial/#Configuration_Of_Selenium_In_PyCharm
"""
Pip Installs:
Selenium
"""
import pyautogui
import time
import subprocess
import pyperclip
import re
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
serv = Service(r"C:\Users\rcowart\Desktop\Robert\Pycharm\DellUpdate - selenium\Driver\chromedriver.exe")
driver = webdriver.Chrome(service=serv)
driver.get("https://www.dell.com/support")
driver.maximize_window()
def SerialNumber():
SerialNumber = 'wmic bios get serialnumber'
result = subprocess.getoutput(SerialNumber)
SerialResult = (result.strip("SerialNumber"))
print(re.sub("[^a-zA-Z0-9]+", "", SerialResult))
pyperclip.copy(re.sub("[^a-zA-Z0-9]+", "", SerialResult))
SerialNumber()
def Step1():
SearchBar = driver.find_element(By.NAME, "entry-main-input-home").send_keys("3Q84KQ2")
SearchBarClick = driver.find_element(By.ID,"txtSearchEs").click()
print("Locating SerialNumber")
Step1()
def Popup():
#30 second popup
if driver.find_element(By.ID, "sec-overlay"):
time.sleep(30.5)
driver.find_element(By.ID, "txtSearchEs").click()
print("Searching: ")
else:driver.find_element(By.ID,"txtSearchEs").click()
time.sleep(3)
Popup()
def DriversAndDownloads():
#refresh bypasses the FeedBack not being found
pyautogui.press("f5")
if driver.find_element(By.ID, "drivers"):
driver.find_element(By.ID, "drivers").click()
print("Successfully Located DriversAndDownloads")
else:
pyautogui.press("f5")
driver.find_element(By.ID, "drivers").click()
print("Refreshing page!")
def FeedBack():
#popup asking for feedback
if driver.find_elements(By.ID, "noButtonIPDell"):
driver.find_element(By.ID, "noButtonIPDell").click()
print("Sucessfully Located FeedBack: ID")
else:
#sleep gives DriversAndDownloads time to refresh/find element without the popup covering it
print("Unable to locate FeedBack!")
pyautogui.press('f5')
time.sleep(3)
DriversAndDownloads()
FeedBack()
def FindDrivers():
#Drop down
if driver.find_element(By.XPATH, "//iframe[@title='Dell Survey']"):
driver.find_element(By.XPATH, "//iframe[@title='Dell Survey']").click()
print("Successfully located FindDrivers: iframe: Dell Survey")
elif driver.switch_to.frame("iframeSurvey"):
driver.find_element(By.ID, "iframeSurvey").click()
print("Successfully located FindDrivers: iframeSurvey")
else:
print("Unable to locate FindDrivers")
FindDrivers()