Skip videos in youtube using Selenium - selenium

My question is like there are 10 videos running one after another in youtube , some of the videos get the "Skip video" option while other's just don't. Now how can I skip the videos which get the option of skipping and just run the other one's as it is. Also youtube uses flash so what api do I need to use for automating it? Thanks

Note : This is an idea which you would have to code. Please don't hesitate.
if(<skip button is available>) {
click Skip button
}

WebElement skipButton = driver.findElement(<locator>);
If(skipButton.isDisplayed())
{
skipButton.click();
}

Related

Recognizing element in an Hybrid App - Android

I am new to Android testing. I am currently trying to automate a scenario. I have attached the snapshot of the app screen:
Scenario:
I need to click on "Clock In".
A screen slides from the bottom as shown in the snapshot.
I need to select an item as shown by the arrow.
The developer is saying that it is a Hybrid app. A lot of confusion here for me as I am able to click on "Clock In", but I am not able to select "DL 380 Memory Upgrade".
Doubts:
How to find whether "DL 380 Memory Upgrade" is in Webview/Native?
If it is an element in the webview, how to locate it? I located "CLOCK IN" as below:
#AndroidFindBy(xpath = "//android.view.View[#resource-id='tab-t0-0']")
private AndroidElement clockInTabBtn;
If its an element in WebView, then its web and you won't find anything in web while searching by resource-id - its native attribute only.
I would recommend to use chrome dev tools for debugging hybrid application.
You can read official docs for setup.
Basically you need:
connect device
go to chrome://inspect/#devices in chrome browser
check phone & allow usb debugging if popup appears
check what webViews chrome spotted and click inspect for the one you need
And now you search for elements and their locators the same way you did in Selenum/Web automation
Don't forget to switch context to WebView in your appium test before you actually searching inside webView.
Good luck!
You can check available view using context and can switch to it using follows code:
Set<string> contextNames = driver.getContextHandles();
for (String contextName : contextNames)
{
System.out.println(contextNames);
//To swicth to webview
if (contextName.contains("WEBVIEW")){
driver.context(contextName);
}
}
Please refer this thread for similar issue: https://github.com/appium/appium/issues/7243

Can i get screenshot of desktop using vuejs

i am working on tracking app using vue.js. I am a new developer.i wanna know is it possible to track mouse click and capture screenshots even if person is on desktop or any where else on browser
This has nothing to do with VueJs specifically. However, you can use HTML5/Canvas/Javascript to take a screenshot, but that's still experimental.
Take a look at this answer: Using HTML5/Canvas/JavaScript to take in-browser screenshots
i have found the solution
i followed the steps here
https://www.webrtc-experiment.com/getScreenId/
these steps allowed me the screen sharing on my webpage and then i use html to canvas to get the image of the video tag

Unsubscribe my own video in opentok

Hi I am using opentok.
When I say
publisher = OT.initPublisher();
session.publish(publisher);
My own video is visible to myself. I want to see only other participants video but not my own. I want my video to be visible to everyone else in the session except me.
How to make this possible.
And can I make other people video to full-screen?
Please help...
You can try this...
var publisher = OT.initPublisher('myPublisherDiv', {display: 'none'});
session.publish(publisher);
Or you can explicitly check on the video using firebug or chrome dev tool and see if it has an existing class or id, then you can just add in a display none on the class ex.
.video-class{
display:none
}

Hide controls - use play / pause

Is there a way when you hide controls and still be able to pause / play video ?
I've seen that when controls are visible the player works fine and reported no other problem.
I tried to find an answer on docs but no luck. So is there a way to do this ?
Many thanks and great work here!
Video.js works like the html5 video video element, where if you turn off controls the only way to control the video is through the API. The easiest way to set up what I think you're talking about would be to do the following.
videojs('my_video_id').on('click', function(){
if (this.paused()) {
this.play();
} else {
this.pause();
}
});

How to play & pause video using Selenium?

Can anyone help me with how to automate play/pause video present on the web page using Selenium..
Thanks in advance...
This is extremely dependent on the browser and the player handling the video. You'll need to use the JavaScript executor, most likely.
I was discussing this last night with a pal and he came up with the following example using the Python variant of Webdriver for a demo video from html5demos.com:
driver = webdriver.Firefox()
driver.get("http://html5demos.com/video")
driver.execute_script('document.getElementsByTagName("video")[0].play()')
You can also "pause" where the "play" is used.
There's a larger question here: what are you actually trying to verify? That simply playing and pausing doesn't throw any errors? Make sure you know what you're validating and that it makes sense to actually work to automate the video test versus just leaving that particular use case to a manual test. (Though you could use the above script to get you to that point!)
** EDIT: Check out this bit of Python code (not mine) which exposes a "Paused" property. Now you could at least validate video loads, starts, and can be stopped. I'm still skeptical of the use of this sort of test, but at least it's a start.
By Using FlashObjectwebDriver !
Now what is FlashObjectWebDriver ?
FlashObjectWebDriver is an interface under Webdriver Library.
FlashObjectWebDriver has a Method called : callFlashObject
callFlashObject method can be over loaded using arguments ie.
callFlashObject(“Play”) : For Playing the Flash
callFlashObject(“Pause”) : For Pausing the Flash
callFlashObject(“Previous”) : For playing previous Flash video
callFlashObject(“next”) : For playing next Flash video
callFlashObject(“SetVariable”, “/:Message) : For displaying the message .
Implementation :
FlashObjectWebDriver flashApp = new FlashObjectWebDriver(driver, "myFlashMovie");
// Pass the URL of video
driver.get("http://demo.guru99.com/flash-testing.html");
Thread.sleep(5000);
flashApp.callFlashObject("Play");
Thread.sleep(5000);
flashApp.callFlashObject("StopPlay");
Thread.sleep(5000);
flashApp.callFlashObject("SetVariable","/:message","Flash testing using selenium Webdriver");
System.out.println(flashApp.callFlashObject("GetVariable","/:message"));