r/SeleniumPython • u/Jealous-University17 • Apr 25 '23
IKM Python 3 Test
My employer asked me to take the "IkM python3" Test For an Entry Level Position as a QA Analyst. What kind of Questions should I expect and be prepared for the test?
r/SeleniumPython • u/Jealous-University17 • Apr 25 '23
My employer asked me to take the "IkM python3" Test For an Entry Level Position as a QA Analyst. What kind of Questions should I expect and be prepared for the test?
r/SeleniumPython • u/EconomicsDelicious88 • Aug 04 '23
How the html works? I mean, it allow you to interact and is "opensource"(I know it's not a programming lang), but if I change some element to a copy of it but with little changes, the server will recognize it like the original? Is a security point, and I want to be protected against any tries of this kind in my page.
r/SeleniumPython • u/[deleted] • Jun 08 '23
Greeting Reddit Forum,
I am having issue with the code-base above. What i'm attempting is to find the checkbox of a website so that it can automatically check it off. Once this is checked, then it's suppose to check off two radio buttons with citation and abstraction, click a window, and then download the information from that window into an excel sheet and go down the page for each article. The goal is to go to the second page afterwards, click the 'Select All', then repeat the steps from above with the addition of clicking the "next" button until all pages are scrapped through.
However, i'm having issue with the code below. The find_element_path isn't working. While the website opens it is not clicking the desired checkbox. The desire checkbox is the 'drone' article.
Any suggestions?
#This code using Selenium, which imports the webdriver that must be imported
#The webdriver helps with automation of the browser using Google Chrome. This must be used in order
#To automate the browser.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
#The following location sets the binary location(Of WebDriver) and headless option into one set.
#The headless option is needed to remove any unnecessary errors that may occur.
options = Options()
#The following is the binary location of the webdriver, not the Path!
options.binary_location = r"C:\Users\April\Documents\chromedriver.exe"
options.add_argument("--headless")
#The following code tells the driver to open up the webdriver using Chrome Browser
driver = webdriver.Chrome()
driver.get('https://ieeexplore.ieee.org/xpl/conhome/9811522/proceeding')
#This part allows the user to hit the enter key to close the window.
input("Press enter to close the browser...")
#Example usage: Click a checkbox
find_element= find_element_by_xpath(<span>My <a>Link</a></span>)
#While loop to keep it checked while it's still toggled.
while checkbox_element.is_selected():
checkbox_element.click()
#while(driver.find_element_by_css_selector == true):
#click(_ngcontent-cmd-c274)
#driver.find_element_by_css_selector("_ngcontent-cmd-c274").click()r/SeleniumPython • u/Puzzleheaded-Tie5827 • Oct 22 '23
r/SeleniumPython • u/Significant-Art3996 • Mar 15 '24
Hi guys,
Does anyone know how I can open multiple brave browsers using Selenium?
I was using
option.add_argument(f"--profile-directory=Profile {i}")
option.add_argument(f"--user-data-dir=BraveSoftware\\Brave-Browser\\User Data")but it gives me the following error when I try to open more than one profile:
File "Python\Python310\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome failed to start: exited normally. (session not created: DevToolsActivePort file doesn't exist) (The process started from chrome location AppData\Local\BraveSoftware\Brave-Browser\Application\brave.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.) I'm not sure what is the issue here
r/SeleniumPython • u/Affectionate-Gold-86 • Mar 11 '24
If anyone can help me I want to know how to record a video using (Selenium Python) while running the test case on my local machine or browser.
r/SeleniumPython • u/warrobe • Aug 17 '23
Hi everyone! This morning I found out that the latest chromedriver version on https://chromedriver.chromium.org/downloads: 114 is not compatible with my current browser version 116.
Does that mean I have to wait until an updated version of the chromedriver becomes available? Many thanks in advance!
r/SeleniumPython • u/dedolent • Jan 11 '23
hello. this is kind of a desperation/frustration post.
i consider myself pretty intermediate when it comes to Python but every attempt at writing a test is met with a brick wall.
so here's an example. maybe someone can give me some insight about what i'm not understanding about Selenium and how to approach it. telling me what specifically i'm doing wrong would be great, too, but i'm really wondering just why this isn't clicking for me in a broader sense.
example:
i am developing a Django web app. i am testing the accounts app. here is one test and it works fine:
class LoginFormTest(LiveServerTestCase):
@classmethod
def setUpClass(cls) -> None:
super().setUpClass()
cls.driver = webdriver.Firefox(
service=FirefoxService(GeckoDriverManager().install()))
cls.driver.implicitly_wait(10)
cls.user = User.objects.create_user(
username="test_user",
password="test_password",
)
cls.user_id = cls.user.pk
@classmethod
def tearDownClass(cls) -> None:
cls.driver.quit()
super().tearDownClass()
def test_login(self):
"""
Simple login loop:
- start at index, click on login link, enter credentials, submit.
"""
self.driver.get(self.live_server_url + reverse_lazy('base:index'))
login_link = self.driver.find_element(by=By.LINK_TEXT, value="Login")
login_link.click()
username_input = self.driver.find_element(by=By.ID, value="id_username")
password_input = self.driver.find_element(by=By.ID, value="id_password")
submit_input = self.driver.find_element(by=By.CSS_SELECTOR, value="input[type='submit']")
username_input.send_keys('test_user')
password_input.send_keys('test_password')
submit_input.click()
expected_url = self.live_server_url + reverse_lazy('accounts:profile', args=[self.user_id])
actual_url = self.driver.current_url # FULL url including host
self.assertEqual(actual_url, expected_url)however, when i pretty much copy and paste this functioning test to do the same thing, but with user registration, it fails.
class RegistrationTest(LiveServerTestCase):
@classmethod
def setUpClass(cls) -> None:
super().setUpClass()
cls.driver = webdriver.Firefox(
service=FirefoxService(GeckoDriverManager().install()))
cls.driver.implicitly_wait(10)
@classmethod
def tearDownClass(cls) -> None:
cls.driver.quit()
super().tearDownClass()
def test_registration(self):
self.driver.get(self.live_server_url + reverse_lazy('base:index'))
login_link = self.driver.find_element(by=By.LINK_TEXT, value="Register an account")
login_link.click()
username_input = self.driver.find_element(by=By.ID, value="id_username")
password_input1 = self.driver.find_element(by=By.ID, value="id_password1")
password_input2 = self.driver.find_element(by=By.ID, value="id_password2")
submit_input = self.driver.find_element(by=By.NAME, value="submit")
username_input.send_keys("test_user")
password_input1.send_keys("vTooGyk5")
password_input2.send_keys("vTooGyk5")
submit_input.click()
expected_url = self.live_server_url + reverse_lazy('accounts:login')
actual_url = self.driver.current_url
self.assertEqual(expected_url, actual_url) the relevant lines of the error message:
selenium.common.exceptions.ElementNotInteractableException: Message: Element <input class="btn btn-primary px-4" name="submit" type="submit"> could not be scrolled into viewthe important difference is that the registration page has a scroll bar, so the submit button is initially out of view.
things i have tried:
submit_input = WebDriverWait(
self.driver, 100).until(
EC.element_to_be_clickable(submit_input))
submit_input.click()Result: same error.
==========================================
ActionChains(self.driver).move_to_element(submit_input).click(submit_input).perform()Result: different error:
selenium.common.exceptions.MoveTargetOutOfBoundsException: Message: (440, 1052) is out of bounds of viewport width (1477) and height (722)==========================================
Attempted a workaround by over-scrolling to an object below the submit button:
footer = self.driver.find_element(by=By.CSS_SELECTOR, value="footer")
a = ActionChains(self.driver)
a.move_to_element(footer)
a.perform()
submit_input.click()Error: same out of bounds error.
==========================================
Finally, I have tried the solution presented here: https://9to5answer.com/selenium-movetargetoutofboundsexception-with-firefox Result: same out of bounds error.
==========================================
so what am is going on? what am i not understanding about how Selenium works?
r/SeleniumPython • u/Small-Resident-6578 • Feb 09 '24
I'm currently facing a challenge with deploying my Flask server application, which utilizes Selenium for web scraping, into a production environment. While I've successfully implemented Selenium for local development using ChromeWebDriver, I'm unsure about the best practices for Dockerizing it and deploying it in a production setting.
Here's a bit of background: I've built a Flask server that scrapes data from X's tweets ( formerly known as twitter ) using Selenium. However, as I prepare to deploy this application into production, I realize that I need guidance on how to effectively containerize it with Docker and manage the Selenium instances.
How can I Dockerize my Flask application along with Selenium dependencies to ensure seamless deployment in a production environment?
What are the best practices for managing Selenium instances within Docker containers?
Are there any specific configurations or optimizations I should consider for running Selenium in a production environment?
I'd appreciate any resources, blogs, or YouTube videos that provide insights into running Selenium in production environments with Flask servers. Whether it's documentation, tutorials, or personal experiences, any guidance would be helpful
from flask import Flask, render_template, request, jsonify
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import json
from time import sleep
app = Flask(__name__)
# Set the path to your chromedriver executable
chromedriver_path = '/path/to/chromedriver'
@app.route('/scrape', methods=['POST'])
def scrape():
if request.method == 'POST':
url = request.json.get('url')
browser = webdriver.Chrome()
# Initialize Chrome driver
try:
# Navigate to the provided URL
browser.get(url)
# print(1)
# Extract title and any other data you need
tweet = browser.find_element(By.XPATH, '//article[@data-testid="tweet"]')
# print(2)
element = WebDriverWait(browser,10).until(EC.presence_of_element_located((By.CLASS_NAME,'css-9pa8cd')))
img = tweet.find_element(By.XPATH,'//img[@class="css-9pa8cd"]').get_attribute("src")
# print(3)
# print(img,"sujal")
# print(4)
# print(5)
user_name_container = tweet.find_element(By.XPATH, '//a[@class="css-175oi2r r-1wbh5a2 r-dnmrzs r-1ny4l3l r-1loqt21"]')
# print(6)
user_name = user_name_container.get_attribute("href")[20:]
# print(8)
name_container = tweet.find_elements(By.XPATH, '//span[@class="css-1qaijid r-bcqeeo r-qvutc0 r-poiln3"]')
name = name_container[6].text
tweet_body = name_container[8].text
time = tweet.find_element(By.TAG_NAME, 'time').text
# print(time)
# print(user_name)
# Add more scraping logic as needed
# Return the scraped data as JSON
return jsonify({
'user_name':user_name,
'name':name,
'tweet_body':tweet_body,
'time':time,
'img':img
})
except Exception as e:
# Handle any errors that may occur during scraping
return jsonify({'error': str(e)})
finally:
# Make sure to close the driver even if an exception occurs
pass
if __name__ == '__main__':
app.run(debug=True)r/SeleniumPython • u/Alexx10990 • Jul 10 '23
I tried Automating microsoft edge in google colab using edge driver but it still give me followig error WebDriverException: Message: unknown error: Microsoft Edge failed to start: exited abnormally.
Code :
import os
from seleniumbase import BaseCase
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class MyTestCase(BaseCase):
def test_login_and_search(self):
# Prompt the user for Microsoft Edge browser sign-in credentials
username = input("Enter your username: ")
password = input("Enter your password: ")
# Set the path to the Microsoft Edge WebDriver executable directory
webdriver_directory = "/usr/local/bin/" # Replace with the actual directory
# Add the WebDriver directory to the PATH environment variable
os.environ["PATH"] += os.pathsep + webdriver_directory
# Create a new instance of the Microsoft Edge driver
self.driver = webdriver.Edge()
# Maximize the browser window (optional)
self.driver.maximize_window()
# Navigate to the Microsoft sign-in page
self.open("https://login.live.com/")
# Wait until the username field is visible and enter the username
self.wait_for_element_visible("name:loginfmt")
self.type("name:loginfmt", username)
self.press_key("name:loginfmt", Keys.RETURN)
# Wait until the password field is visible and enter the password
self.wait_for_element_visible("name:passwd")
self.type("name:passwd", password)
self.press_key("name:passwd", Keys.RETURN)
# Wait until the search box is visible and enter the search query
self.wait_for_element_visible("name:q")
self.type("name:q", "hello")
self.press_key("name:q", Keys.RETURN)
# Close the browser
self.driver.quit()MyTestCase().test_login_and_search()
Error : WebDriverException Traceback (most recent call last) in <cell line: 50>() 48 49 # Run the test case ---> 50 MyTestCase().test_login_and_search()
6 frames /usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response) 243 alert_text = value["alert"].get("text") 244 raise exception_class(message, screen, stacktrace, alert_text) # type: ignore[call-arg] # mypy is not smart enough here --> 245 raise exception_class(message, screen, stacktrace)
WebDriverException: Message: unknown error: Microsoft Edge failed to start: exited abnormally. (unknown error: DevToolsActivePort file doesn't exist) (The process started from msedge location /usr/bin/microsoft-edge is no longer running, so msedgedriver is assuming that msedge has crashed.) Stacktrace:
NOTE : I have used same latest version of edgedriver and same latest version microsoft edge browser and the path is also correct and the selenium version is also latest But I'm still getting Error. This code is running on my local machine , but It's not running on Google Colab.
If you want to see the steps
https://colab.research.google.com/drive/1svimGMvBEBxhtZ3UZ6OumXxa63O2RV4x?usp=sharing
r/SeleniumPython • u/[deleted] • Aug 07 '23
r/SeleniumPython • u/zero_opacity • Aug 30 '23
I’m looking for a sample project with a basic test suite that I could use when testing how to set up and configure Selenium Grid in a CI/CD pipeline. Is anyone aware of like a starter project I could just use vs writing my own?
r/SeleniumPython • u/[deleted] • Apr 29 '24
Hi there 👋 Pretty experienced shitty dev here 👋
So I'm currently trying to automate a process for me using Selenium but, I'm at a point where I have tried every xpath possible and the popup I want to click just doesn't want to go away :(
Because I usually do Reddit from my phone I don't have the code with me rn but what do you do when you have tried every path? The weird thing is that it should be possible to click it. It isn't any external program like a extension or something like that, the element is there in HTML so it should be clickable.
So yeah what is your step process of debugging selenium and maybe there is a thing I have overlooked:)
r/SeleniumPython • u/[deleted] • Jun 27 '23
Cypress and selenium are so similar, I am not sure which platform to learn. Selenium also has different components.
https://www.instagram.com/reel/Ct_FNStLNqQ/?utm_source=ig_web_copy_link&igshid=MzRlODBiNWFlZA==
which platform to learn.
PS. I've been trying to switch profiles.
r/SeleniumPython • u/Bobydude967 • Sep 13 '23
r/SeleniumPython • u/Mediocre-Army-3899 • Jan 04 '24
I used undetected_chromedriver but this is still target me
r/SeleniumPython • u/Darshan2501 • Mar 15 '23
r/SeleniumPython • u/Straight_Molasses891 • Oct 31 '23
hello to all interested. I have been looking for a solution to my question for more than a month and have tried more than one option. I have my own tradingview strategy, its results depend on the selection of parameters. I want to find a way to automate the selection of parameters to find the most profitable combination. I used chat gpt to write code in python, it even worked as it should. but there was a problem with access to ccxt libraries for a maximum of 2-5 days depending on the exchange. now I am thinking about whether it is possible to solve my problem with the help of selenium.
anyone with a similar experience would love to hear your thoughts
r/SeleniumPython • u/TileJam209 • Sep 05 '23
I am new to web scraping and Python. I am trying to scrape the sector performance chart on https://digital.fidelity.com/prgw/digital/research/sector . I know how to use the basics of selenium. When I use a chrome driver to find an element by xpath, for example,
driver.find_element(By.XPATH, value = '//*[@id="market-sector-performance-table"]/tbody/tr[1]/td[2]') to get the S&P 500 performance for 1 month (-1.59%), it says could not find element with that xpath. On some websites that I scrape, this works, on others like the Fidelity site, it doesn't. Why is this? Does it have anything to do with JavaScript or that the website is dynamical? What is the work-around to get the elements I need in this case?
Similarly, I have tried using BeautifulSoup to get the data, and I get empty lists with no data, or errors saying elements could not be found.
How specifically would I scrape the Fidelity chart with Python? Specific code would be very helpful.
r/SeleniumPython • u/zodman • Jul 18 '23
r/SeleniumPython • u/[deleted] • Jul 16 '23
I have just started using selenium and am wondering if it is possible to navigate to this site https://kick.com/, open a channel, navigate to the clips tab, open a clip, and then copy the clip url. I am having issues loading the videos which I have seen could be a limitation of selenium, as it is not able to handle the player?
r/SeleniumPython • u/[deleted] • Jul 11 '23
Technically advantages and disadvantages of hacking as well as positive and negative effects of hacking roll out improvements in the security highlights or the whole framework for satisfying the point which varied from the original purpose.
Hackers have various explanations for getting through system security. Some do it only for the test, others for data, some for fame and some to hone their programming abilities.
Whatever the reason, hacking for good cause is a myth as the hacking causes damage to the computing gadgets of people and organizations, some of the time bringing about a large number of dollars lost.
So, the question what is the use of hacking? And how to use hacking tools for only good reasons? But anything which exists has their positive and negatives sides, even the man or a gadget.
Thus to understand hacking correctly, we need to know both the advantages and disadvantages of hacking with the positive and negative effects of hacking as well.
Below given some of the positive and negative effects of hacking:
Positive effects of hacking:Positives of hacktivism securing the Data
Most of the circumstances organizations also mastermind hacking rivalry for knowing the glitch in their framework. Benefits of hacking encourage them to settle the patch and keep their information secured. Many organizations employ programmers for keeping a check for the bugs and the glitch in their information security. This is yet another advantage of ethical hacking.
Developing:
Yes, development isn’t just done by innovative heads yet additionally by the hackers. In the prior days, the hackers known as phone phreakers utilized shrieks and blue boxes to hack for good in the phone lines for making free calls at whatever point they need. It was one of the previous phreakers, Steve Jobs, who has made the most secured and complex phone at Apple. Like that, hackers as well break down the codes and after that reassemble them making something new and imaginative.
Examples of good hackers: Mark Zuckerberg was a hacker as well, and he made Facebook out of it. The organizer of Linux was a hacker also. Their insight into hacking has driven them in making awesome comings.
Benefits of computer hacking for Society
Many large associations, mutually, take activities for taking care of the social issues. They hold events connected to the good hacking tools with the reason for understanding numerous social problems such as following the signal quality of WiFi in the territories hit with calamity, following a broken wheelchair lift or a phone and mapping safe zones by following the occurrences of inappropriate behaviour.
Positive hacking is additionally used to catch the terrorist messages and arranging an activity before they plan any attack. Hacking for good reasons can as well uncover the wrongdoing since now the vast majority of the information and exchanges are digital.
Negative effects of hacking:
Reduced Privacy
At the point when programmers access your PC, they can see everything. Since a great part of the individual, proficient and monetary parts of our lives have moved on the web; we chance to lose considerably more than cash or data. As the disadvantages of technology hackers the Internet, security restricted, for the most part by decision. A hacker with access to your email, long range interpersonal communication records and personal photographs can rapidly devastate that privacy.
Money related Losses
Consistently, reports from hacked organizations uncover stunning money related misfortunes subsequently. In 2011, Sony lost $170 million because of a hack of their PlayStation framework. Additionally, in 2011, CitiGroup lost $2.7 million, and AT&T lost $2 million due to disadvantages of hacking. The cost of fixing the gaps in security, reimbursing client misfortunes, tending to claims and weathering shutdowns of their frameworks added to those huge numbers. Although, for a person who loses his credit card data to bad hackers, but, the cost of repairing harm and finding the guilty party can be more important.
Harmed Reputation
Organizations that get hacked have a more concerning issue than merely paying for the underlying harm expenses and claims. Reputation harm can wreck to an organization’s fortunes. In a case the bank has been traded off different circumstances, clients are less inclined to give them their data. The same goes for retailers who lose data due to disadvantages of ethical hacking. These organizations lose business after some time due to harmed or exhausted reputations. People with stolen ways of life because of hacking have a comparable reputation issue with regards to their credit ratings.
Loss of Information
Hacking regularly brings about lost information because of documents being erased or changed. Client data and request data can be stolen and erased, or a break of best mystery data could cause certifiable security issues results in the negative side of hacking. Servers at the NASA, Interpol, Pentagon and FBI have all been traded off at different focuses in the previous ten years. Once in a while, these hackers even post data from these legislative associations on the web, which could in principle cause anxiety between nations and becomes the reasons why hacking is bad**?**
Thus, there are advantages and disadvantages of hacking, which it carries all around. It can be utilized for positive things and negative things, regardless of what the reason, everything, including hacking, has a beneficial outcome/side. Security will get more tightly as the years pass by, yet we don’t have to add to the offensive side.
r/SeleniumPython • u/No-Nefariousness3465 • Mar 17 '24
Is there any online tool or library that is used to convert Python code to selenium .side file?