python - 在 Python 中返回上一个浏览器窗口
问题描述
我正在用 Python selenium 编写脚本并尝试返回到以前的浏览器窗口。当代码运行时,它会点击 print_print 并转到不同 url 链接中的打印设置页面。我正在尝试关闭它打开的打印设置窗口并转到上一个窗口。
#!/usr/bin/env python
# coding: utf-8
from selenium import webdriver # Import module
from webdriver_manager.chrome import ChromeDriverManager # import chromedrivermanager
from bs4 import BeautifulSoup
from selenium.webdriver.common.keys import Keys
import csv
from time import sleep
driver = webdriver.Chrome(ChromeDriverManager().install())
sleep(2)
import pandas as pd
data=pd.read_csv("C:/Selenium/boltsemployees.csv")
# Login
for i in range(0,data.shape[0]):
driver.get("https://test.first.bank/bolts/launchpad/")
First=data['First'][i]
Last=data['Last'][i]
Email=data['Email'][i]
sleep(2)
user_id=driver.find_element_by_xpath("/html/body/div/div/ui-view/logicontent/form/div/md-input-container")
sleep(2)
user_id.send_keys("login")
password=driver.find_element_by_xpath("/html/body/div/div/ui-viecontent/form/div/md-input-container[2]/input")
password.send_keys("password")
login_btn=driver.find_element_by_xpath("/html/body/div/div/ui-view/login/dcontent/form/button").click()
initial_package_submit=driver.find_element_by_xpath("/html/body/div[3]/md-dialog/div/md-tabs/md-tabs-content-wrapper/md-tab-content[2]/div/blt-tab/div/ng-transclude/ng-include/div/blt-tab-content/div/div/div/div[2]/ng-transclude/div/div[2]/div[2]/blt-button[2]/button")
initial_package_submit.click()
sleep(2)
esign=driver.find_element_by_xpath("/html/body/div[3]/md-dialog/div/md-tabs/md-tabs-content-wrapper/md-tab-content[2]/div/blt-tab/div/ng-transclude/ng-include/div/blt-tab-content/div/div/div/div[2]/ng-transclude/div/div[1]/md-list/md-list-item[2]/div/button").click()
sleep(2)
esign_decline=driver.find_element_by_xpath("/html/body/div[3]/md-dialog/div/md-tabs/md-tabs-content-wrapper/md-tab-content[2]/div/blt-tab/div/ng-transclude/ng-include/div/blt-tab-content/div/div/div/div[2]/ng-transclude/div/div[2]/div[1]/blt-button/button/div[1]")
esign_decline.click()
sleep(2)
print_btn=driver.find_element_by_xpath("/html/body/div[3]/md-dialog/div/md-tabs/md-tabs-content-wrapper/md-tab-content[2]/div/blt-tab/div/ng-transclude/ng-include/div/blt-tab-content/div/div/div/div[2]/ng-transclude/div/div[2]/blt-button[1]/button")
print_btn.click()
sleep(2)
print_print=driver.find_element_by_xpath("/html/body/div[3]/div[3]/md-dialog/md-dialog-actions/button[2]")
print_print.click()
sleep(2)
解决方案
推荐阅读
- swift - Swift - 调度队列和 U/I 串行运行
- java - 如何解决:预期的数组类型,找到 int?在使用数组而不是列表的冒泡排序中
- php - 运行自定义帖子类型的查询时,为什么“>”会在 wordpress 中关闭我的 php 查询?
- excel - 如何根据百分比对学生的排名进行排名
- python - 以编程方式递归查找所有正在使用的函数
- google-colaboratory - 在 Google Colaboratory 机器上打开端口
- docker-compose - 我将springboot jar文件构建到镜像中,但是当我运行它时,我无法连接mysql
- azure - azure - 使用 DB 自动缩放 VM
- javascript - 如何在 vuetify 和 typescript 中以编程方式聚焦 v-textarea?
- jquery - 在表格视图 ASP.NET MVC 中显示从 AJAX 请求到控制器的动态数据