selenium-webdriver

How to get Json response by selenium webdriver using Java?

那年仲夏 提交于 2021-02-11 13:57:01
问题 I'm trying to get Json response by selenium webdriver. How to get it as a Json format. Currently what I get is a String format. Here is what I'm trying to get: {"id":377,"text":"Playing Sudoku is fun!"} <pre style="word-wrap: break-word; white-space: pre-wrap;">{"id":377,"text":"Playing Sudoku is fun!"}</pre> Here is my code: import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class GameTestSelenuim { public static void

How to use WebDriverWait from Selenium properly through Python?

吃可爱长大的小学妹 提交于 2021-02-11 13:54:02
问题 Just thought I'd add an edit now that this has been resolved. Replacing those 2 time.sleep() took my program from 180 seconds down to 30. WebDriverWait creates a substantial improvement in runtime. Just trying to determine if I'm setting up WebDriverWait correctly. This is my working script, I use time.sleep() for x,sequence in enumerate(table.find_elements_by_xpath('//*[@id="gwzSngrOrderResultPanelRoot"]/table/tbody/tr/td[9]'),1): driver.find_element_by_xpath(f'//*[@id=

How do I execute a function from external Javascript file using Python and Selenium?

柔情痞子 提交于 2021-02-11 13:32:58
问题 I am new to Selenium and am stuck trying to get it to automatically open links that look like this: <a href='javascript:void(0)' onclick=javascript:myFunction(argument1, argument2)>Click here</a> The myFunction function is in an external .js file. I couldn't fetch it from the server (this is material for another question) so I copied and pasted it into a text file that I have saved on my hard drive. I load and run it with with open ('MY_PATH', 'r') as f: ext_js = f.read() driver.execute

Click “Download csv” button using Selenium and Beautiful Soup

为君一笑 提交于 2021-02-11 12:57:58
问题 I'm trying to download the csv file from this website: https://invasions.si.edu/nbicdb/arrivals?state=AL&submit=Search+database&begin=2000-01-01&end=2020-11-11&type=General+Cargo&bwms=any To do so, I need to click the CSV button, which downloads the CSV file. However, I need to do this for multiple links, which is why I want to use Selenium to automate the task of clicking on the link. The code I have currently runs, but it does not actually download the csv file to the designated folder (or

Click “Download csv” button using Selenium and Beautiful Soup

橙三吉。 提交于 2021-02-11 12:57:00
问题 I'm trying to download the csv file from this website: https://invasions.si.edu/nbicdb/arrivals?state=AL&submit=Search+database&begin=2000-01-01&end=2020-11-11&type=General+Cargo&bwms=any To do so, I need to click the CSV button, which downloads the CSV file. However, I need to do this for multiple links, which is why I want to use Selenium to automate the task of clicking on the link. The code I have currently runs, but it does not actually download the csv file to the designated folder (or

.send_keys in selenium is messing up indentation when using with pyperclip

三世轮回 提交于 2021-02-11 12:56:55
问题 I'm copying some code from Leetcode to paste in Github, I use pyperclip to paste and copy into clipboard using Selenium. Everything is saved as a string but when i use driver.send_keys(pyperclip.paste()) this is what happens I've verified that the issue is not Leetcode or Github by copying from Leetcode on my own and then pasting it to Github. The issue is pyperclip because when I paste this is the format However the issue clearly gets amplified when I use driver.send_keys() because as you

How to scrape a website thet has username and password?

你说的曾经没有我的故事 提交于 2021-02-11 12:49:43
问题 I am trying to scrape a website and make my program know all the buttons and links that inside of that website but my problem is that to get to the first page I need to enter a username and a password and then scraping the page that shows after that and every time it's scraping to the page with the password and the username someone knows how to do that? because I don't know-how this is the code that I tried: import requests import time from bs4 import BeautifulSoup from selenium import

How to run a background task in Heroku?

ⅰ亾dé卋堺 提交于 2021-02-11 12:46:41
问题 I have already build a a python app and deployed it using Flask and Python . Here is my Skelton of my code. #app.py @app.route('/', methods=['GET']) def login(): '''login process''' @app.route('/reset-password', methods=['GET']) def reset_password(): '''reset password process''' @app.route('/add-psa', methods=['GET']) def add_user(): '''add user process''' if __name__ == '__main__': app.debug = True app.run(use_reloader=False, threaded=True) Deployed app work fine in the Heroku. But sometime

How to run a background task in Heroku?

自闭症网瘾萝莉.ら 提交于 2021-02-11 12:46:19
问题 I have already build a a python app and deployed it using Flask and Python . Here is my Skelton of my code. #app.py @app.route('/', methods=['GET']) def login(): '''login process''' @app.route('/reset-password', methods=['GET']) def reset_password(): '''reset password process''' @app.route('/add-psa', methods=['GET']) def add_user(): '''add user process''' if __name__ == '__main__': app.debug = True app.run(use_reloader=False, threaded=True) Deployed app work fine in the Heroku. But sometime

Selenium IDE python code export, doesnt work

回眸只為那壹抹淺笑 提交于 2021-02-11 12:33:21
问题 I want to use Selenium IDE to do some easy tasks in Chrome an then export the code to python and execute there. However, when I execute the exported code in python nothing happens. # Generated by Selenium IDE import pytest import time import json from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.support import expected_conditions from selenium.webdriver.support.wait import