Ejemplo n.º 1
0
import time
from selenium import webdriver
from highlightObject import highlight

driver=webdriver.Chrome(executable_path="C:/Users/shaik/PycharmProjects/drivers/chromedriver_win32/chromedriver.exe")
driver.get("http://demo.automationtesting.in/Windows.html")


ele1=driver.find_element_by_xpath("//div[@id='Tabbed']/a/button")
highlight(ele1)
ele1.click()
whandle=driver.window_handles

for i in whandle:
    print("** window title is ** ",i.title())
    driver.switch_to.window(i)
    print(" browser titile is : ",driver.title)
    if driver.title=="Sakinalium | Home":
        driver.close()
driver.switch_to.window(whandle[0])
#driver.get_window_position("Cdwindow-94083972Dda002E6C781A37B3B81496B")
chandle=driver.current_window_handle
print("current window active is : ",chandle)

time.sleep(5)
driver.quit()
import time

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys

from highlightObject import highlight

driver = webdriver.Chrome(
    executable_path=
    "C:/Users/shaik/PycharmProjects/drivers/chromedriver_win32/chromedriver.exe"
)
driver.get("http://swisnl.github.io/jQuery-contextMenu/demo.html")
elebtn = driver.find_element_by_xpath(
    "//span[@class='context-menu-one btn btn-neutral' and text()='right click me']"
)
highlight(elebtn)
actions = ActionChains(driver)
actions.move_to_element(elebtn).context_click().send_keys(
    Keys.ARROW_DOWN).send_keys(Keys.RETURN).perform()
time.sleep(5)
driver.switch_to.alert.accept()
time.sleep(5)

driver.quit()
import time

import highlightObject
from highlightObject import highlight
from selenium import webdriver
from selenium.webdriver.common.by import By
try:
    driver = webdriver.Chrome(
        executable_path=
        "C:/Users/shaik/PycharmProjects/drivers/chromedriver_win32/chromedriver.exe"
    )
    driver.get("https://testautomationpractice.blogspot.com/")
    driver.maximize_window()
    time.sleep(2)
    highlight(driver.find_element_by_xpath("//div[@id='HTML9']"))
    highlight(driver.find_element_by_xpath("//div[@id='HTML9']//div"))
    clickbtn = driver.find_element(
        By.XPATH, "//div[@id='HTML9']//div[@class='widget-content']//button")
    highlight(clickbtn)
    clickbtn.click()
    driver.switch_to.alert().accept()
    time.sleep(5)
    clickbtn.click()
    driver.switch_to.alert().dismiss()
    time.sleep(5)
finally:
    driver.quit()
Ejemplo n.º 4
0
actions=ActionChains(driver)
actions.move_to_element(admin).perform()
time.sleep(1)
actions.move_to_element(usermgtmnu).perform()
time.sleep(1)
actions.move_to_element(usersmnu).perform()
time.sleep(1)
usersmnu.click()
#****** we can combine all the above actions in single line
#actions.move_to_element(admin).move_to_element(usermgtmnu).move_to_element(usersmnu).click().perform()

time.sleep(5)


#******* double click operations **********
driver.get("http://testautomationpractice.blogspot.com/")
copybtn=driver.find_element_by_xpath("//div[@id='HTML10']//button[text()='Copy Text']")

driver.execute_script("arguments[0].scrollIntoView();",copybtn)
highlight(copybtn)
actions=ActionChains(driver)


actions.double_click(copybtn).perform()
time.sleep(5)



driver.close()

Ejemplo n.º 5
0
import time
from highlightObject import highlight
from selenium import webdriver

driver = webdriver.Chrome(
    executable_path=
    "C:/Users/shaik/PycharmProjects/drivers/chromedriver_win32/chromedriver.exe"
)
driver.get("https://seleniumhq.github.io/selenium/docs/api/java/index.html")
time.sleep(5)
driver.switch_to.frame("packageListFrame")
ele1 = driver.find_element_by_link_text("org.openqa.selenium")
highlight(ele1)
ele1.click()
driver.switch_to.default_content()

driver.switch_to.frame("classFrame")
ele2 = driver.find_element_by_link_text("com.thoughtworks.selenium")
highlight(ele2)
ele2.click()

ele3 = driver.find_element_by_xpath(
    "//table[@class='typeSummary']//td[@class='colFirst']/a[text()='SeleniumException']"
)
highlight(ele3)
ele3.click()
time.sleep(3)
driver.get_screenshot_as_file("screenshot.png")
driver.quit()