How to click on a video using Selenium - python

I'm new to coding using python and it's libraries, and also new to stackoverflow so I apologize if I'm not acquainted to some things.
Anyway to the question. I'm trying to write code that automates playing a video from the website that. Here's an example link:
http://www.shush.se/index.php?id=164&show=southpark
I've tried these methods:
driver.find_element_by_id("playerload").click()
driver.find_elements_by_xpath("./html/body/table/tbody/tr/td/div[#id='load']/div[#class='player']/div[#id='playerload']/div[1]")
But nothing happens. The program exits without error but the video does not
start playing.
I tried clicking a the id "jw6playerid5040619_wrapper" but the number associated with that changes every time a page loads.
Any advice? Thanks in advance!

Even though you don't know the exact id, you know that it will start with "jw6playerid". The following works for me:
elements = driver.find_elements_by_xpath("//*[contains(#id, 'jw6playerid')]")
elements[0].click()

Related

Question about using selenium+pyautogui to upload file

Recently I need to upload my dataset on a website, the first part works fine on selenium.
However, after I click the 'upload' button, a windows file broswer pops-up.
And after searching online, I finally make it work by using pyautogui, code:
pyautogui.write('K:\Github\###\data\global\Global_PM_corT.csv') # enter file with path
pyautogui.press('enter') # click ok
My question is, I want to use above process on Github Action.
So, i changed:
'K:\Github\###\data\global\Global_PM_corT.csv'
to:
'./data/global/Global_PM_corT.csv'
and it's not working.
I think there is some error when using relative path with pyautogui.
So, i was wondering if someone could help me achieve this? Thanks in advance:)
P.S.
its working right now.
I first read the dataset by
pd.read_csv('path')
then write it on github action
to_csv('C:\\Global_PM_corT.csv')
then I can use absolute path with pyautogui:)
However, I still want to know if a better way to achieve this
Please try this:
'./data/global/Global_PM_corT.csv'

how do I check for button press in python flask and EJS? Is it possible?

i am trying to make a program that checks every time a specific button is pressed, this would be done with python, i am thinking of using flask however i am not sure how to do it as the website is in EJS. please help and give suggestions on how to do it and if possible code snippets.
I can't find any docs on this, so please help.
Thanks

ElementNotInteractableException error message

I have been working on some RobotFramework stuff and I am having an issue. I am trying to access ta set of links that appear when the settings menu is pressed. I assume that we would need to do some window switching but am having trouble with it as I am pretty new to RF and Python. Would anyone be able to point in the direction of some assistance? I have tried using the documentation but I just cant seem to get it.
Thank you
p.s this is some code where I seem to be getting the issue
Go to http://localhost/index.php?redirect=0
Click Element id:quickaccess-popover-content
Click Element //*[#id="quickaccess-popover content"]/div[2]/div[2]/ul/li[1]/a

Youtube + Selenium ChromeDriver (Python) - How to loop youtube video?

Already searched related questions but can't get solution.
How to use Python Selenium ChromeDriver to loop Youtube video?
Thanks a lot!
It MIGHT be useful for your purposes since it's not quite clear.
Once the video starts playing, right-click on the video screen and selects the option Loop.
As follows:
https://giphy.com/gifs/xUSGPLMaJQaEnkcwTR/html5
However, it may be not enough because after the video repeats itself for a while (approximately 20x) it just goes to the next video.
A workaround is to use javascript in the browser itself.
After click on Loop, open chrome dev tools console and type the following into it:
document.getElementById("loop").nextSibling.__shady_native_nextSibling.childElementCount = 2
The value here is arbitrarily and I cannot explain why, I only know that it should be greater than 1.
Doing so, the video should repeat itself indeterminately.

Python selenium: Firefox auto download everything

I am trying to download a csv file from a website and no matter how many MIME's I try for both saving and opening, the dialog box still appears. Is there a way to cover all MIME's at once or anything that might pop up?
Right now I'm using:
fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/html")
fp.set_preference("browser.helperApps.neverAsk.openFile","text/html")
And other variations including a ton more MIME's. How can I auto download regardless of the MIME?
I solved my question with this:
fp.set_preference("browser.helperApps.neverAsk.saveToDisk","application/octet-stream")
fp.set_preference("browser.helperApps.neverAsk.openFile","application/octet-stream")
I had multiple preference statements, and I think that is what the problem was. Now I only have this one active and don't have any problems. Hope this can help someone else.

Categories