Пример #1
0
 def xh(self):
     t = True
     time.sleep(1)
     while t:
         driver.execute_script("window.scrollBy(0,1000)")
         try:
             driver.find_element('link_text', '没有更多推荐了,返回首页').click()
             time.sleep(1)
             t = False
         except:
             self.xh()
Пример #2
0
 def find_element(self, loc):
     try:
         WebDriverWait(self.driver, 15).until(
             lambda driver: driver.find_element(*loc).is_displayed())
         return self.driver.find_element(*loc)
     except:
         print u"%s 页面中未能找到 %s 元素" % (self, loc)
 def test1_flight_booking(self):
     driver = self.driver
     # driver.get("http://newtours.demoaut.com/")
     login = SignOn(driver)
     login.click_home()
     login.login_user(username=td.testData("username"),
                      password=td.testData("password"))
     login.click_submit()
     flight_details = driver.find_element(
         By.XPATH, "/html/body/div/table/tbody/tr/td[2]/table/tbody/tr["
         "4]/td/table/tbody/tr/td[2]/table/tbody/tr["
         "5]/td/form/table/tbody/tr[1]/td/font/font/b/font/font").text
     self.assertEqual("Flight Details", flight_details,
                      "Login Un-Successful")
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.remote.webelement import WebElement
import re
from selenium.webdriver.support.color import Color


driver = webdriver.Chrome(executable_path=r"C:\Users\Dell\PycharmProjects\seleniumwebd\Selenium\drivers\chromedriver")

driver.get("https://www.tui.pl/")

print(driver.title)
print(driver.current_url)

driver.find_element(By.CLASS_NAME, "my-tui").click()
time.sleep(2)

driver.switch_to.window(driver.window_handles[1])

email = driver.find_element(By.ID, "email")
password = driver.find_element(By.ID, "pass")

email.clear()
password.clear()

rgb = email.value_of_css_property('background-color')
hex = Color.from_string(rgb).hex
print("E-mail input color is: ", hex)

rgb = password.value_of_css_property('background-color')
Пример #5
0
import time

import driver as driver
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import by
from selenium.webdriver.common.by import by

s = Service("C:\\chromedriver.exe")
driver = webdriver.Chrome(service=s)
driver.get("https://rahulshettyacademy.com/seleniumPractise/#/")
driver.find_element("css selector", "input.search-keyword").send_keys("ber")
time.sleep(4)
#count= len(driver.find_element_by_xpath("//div[@class='products']/div"))
#assert count==3
button = driver.find_element_by_xpath(
    "//div[@class='product-action']/button").click()
#b=driver.find_element_by_xpath("//div[@class='product-action']/button")
print("hiiiiiii:", button)
#for buttons in button:
# buttons.click()

driver.find_element_by_css_selector("img[alt='Cart']").click()
###driver.find_element_by_xpath("//button[text()='PROCEED TO CHECKOUT']/").click()
##hello