Category : selenium

from selenium import webdriver # Chrome Path driver = webdriver.Chrome() driver.get("https://www.sap.com/about/events/2021-05-25-online-pe-payment-processing-sap.html") element = driver.page_source remove_header = element.split("</header>") remove_header_footer = remove_header[1].split("<footer>") This will remove header and footer from driver.page_source . Is there any solution that I can get text from remaining part of HTML source. (Only the text) Source: Python-3x..

Read more

Please find the attached image i want to fetch the Admins and moderators name and href link . i have tried below : grp="https://m.facebook.com/groups/162265541050378?view=members&ref=m_notif&notif_t=group_r2j_approved" driver.get(grp) root1=driver.find_element_by_id("//*[@id=’rootcontainer’]") if root1>0: admin=driver.find_elements_by_xpath("//*[@class=’_4kk6 _5b6s’]") ilink = admin.get_attribute(‘href’) ilink2=admin.get_attribute(‘<a>’) print(ilink) error selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="//*[@id=’rootcontainer’]"]"} (Session info: chrome=91.0.4472.101) Source: Python-3x..

Read more

from selenium import webdriver driver = webdriver.Chrome() driver.get(‘https://www.sap.com/about/events/2021-05-25-online-pe-payment-processing-sap.html’) element = driver.find_element_by_xpath("/html/body") print(element.text) driver.close() <html> <head> <body> <div> <header>….<header> <main> <div> <header> … <header> … … … <footer>…<footer> Is there a solution using selenium python to get text from main by removing the text from 1st header and below footer. I cannot use xpath for main ..

Read more

def addtocart(): driver.get("https://www.mrporter.com/en-gb/mens/product/nike/shoes/low-top-sneakers/space-hippie-04-recycled-stretch-knit-sneakers/19971654707345242") #driver.get("https://www.mrporter.com/en-gb/mens/product/nike/shoes/low-top-sneakers/plus-sacai-blazer-low-colour-block-leather-sneakers/10163292708776845?ntfyeu=jo5suw") txt = driver.find_element_by_xpath("/html/body/main/div/div[2]/div/div[1]/div[2]/div[8]/div[2]").text while "Sorry, this item is sold out" in txt: txt = driver.find_element_by_xpath("/html/body/main/div/div[2]/div/div[1]/div[2]/div[8]/div[2]").text time.sleep(2) driver.refresh() print("Item out of stock , waiting for product") else: print("The product is in stock!") #Locates dropdown menu and clicks it dropdown = driver.find_element_by_xpath("/html/body/main/div/div[2]/div/div[1]/div[2]/div[6]/div/div/div") dropdown.click() select=Select(driver.find_element_by_class_name("CombinedSelect11__field CombinedSelect11__field–placeholderText CombinedSelect11__field–nativeSelect")) print(len(select.options)) addtocart() Im tying to Locate the ..

Read more

Everyone. I hope you are going well. I have one problem to scrap the data from a specific URL. driver = webdriver.Chrome() driver.set_window_size(1200, 800) driver.get(DEGIRO_URL) loginUsername = driver.find_element_by_xpath("//input[@id=’username’]") loginPassword = driver.find_element_by_xpath("//input[@id=’password’]") loginBtn = driver.find_element_by_xpath("//button[@type=’submit’]") loginUsername.send_keys(LOGIN_USERNAME) loginPassword.send_keys(LOGIN_PASSWORD) loginBtn.click() try: myElem = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//button[@class=’duvfw-AB’]"))) myElem.click() print ("Page is ready!") except TimeoutException: print ("Loading took too much ..

Read more