i need to click on the iframe video











up vote
-1
down vote

favorite












i need to click on this iframe video,



<div class="videoWrapper" style="" xpath="1"> 
<iframe width="854" height="480" src="xxxxxxx" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""></iframe></div>


Code for switching to frame



driver.switchto().frame("videoWrapper");


i tried with these Logic's ,



Logic 1 :



WebElement video = driver.findElement(By.xpath("//*[@id='player_uid_840828282_1']/div[4]/div[1]"));

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].play();", video);


Logic 2 :



JavascriptExecutor js = (JavascriptExecutor) driver;
js .executeScript("document.getElementById("video").play()");


But it is not Working , please clear me this out guys!










share|improve this question
























  • driver.findElements(By.tagName("iframe")); then write your logic
    – bhupathi turaga
    Nov 8 at 10:53












  • driver.switchTo().frame(0); if u have two or more then 0,1,2...
    – bhupathi turaga
    Nov 8 at 10:54








  • 1




    driver.switchTo().frame(driver.findElement(By.ClassName("videoWrapper")));
    – bhupathi turaga
    Nov 8 at 10:59










  • videoWrapper is the style class of a div, not an iframe ID.
    – Selaron
    Nov 8 at 10:59















up vote
-1
down vote

favorite












i need to click on this iframe video,



<div class="videoWrapper" style="" xpath="1"> 
<iframe width="854" height="480" src="xxxxxxx" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""></iframe></div>


Code for switching to frame



driver.switchto().frame("videoWrapper");


i tried with these Logic's ,



Logic 1 :



WebElement video = driver.findElement(By.xpath("//*[@id='player_uid_840828282_1']/div[4]/div[1]"));

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].play();", video);


Logic 2 :



JavascriptExecutor js = (JavascriptExecutor) driver;
js .executeScript("document.getElementById("video").play()");


But it is not Working , please clear me this out guys!










share|improve this question
























  • driver.findElements(By.tagName("iframe")); then write your logic
    – bhupathi turaga
    Nov 8 at 10:53












  • driver.switchTo().frame(0); if u have two or more then 0,1,2...
    – bhupathi turaga
    Nov 8 at 10:54








  • 1




    driver.switchTo().frame(driver.findElement(By.ClassName("videoWrapper")));
    – bhupathi turaga
    Nov 8 at 10:59










  • videoWrapper is the style class of a div, not an iframe ID.
    – Selaron
    Nov 8 at 10:59













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











i need to click on this iframe video,



<div class="videoWrapper" style="" xpath="1"> 
<iframe width="854" height="480" src="xxxxxxx" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""></iframe></div>


Code for switching to frame



driver.switchto().frame("videoWrapper");


i tried with these Logic's ,



Logic 1 :



WebElement video = driver.findElement(By.xpath("//*[@id='player_uid_840828282_1']/div[4]/div[1]"));

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].play();", video);


Logic 2 :



JavascriptExecutor js = (JavascriptExecutor) driver;
js .executeScript("document.getElementById("video").play()");


But it is not Working , please clear me this out guys!










share|improve this question















i need to click on this iframe video,



<div class="videoWrapper" style="" xpath="1"> 
<iframe width="854" height="480" src="xxxxxxx" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""></iframe></div>


Code for switching to frame



driver.switchto().frame("videoWrapper");


i tried with these Logic's ,



Logic 1 :



WebElement video = driver.findElement(By.xpath("//*[@id='player_uid_840828282_1']/div[4]/div[1]"));

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].play();", video);


Logic 2 :



JavascriptExecutor js = (JavascriptExecutor) driver;
js .executeScript("document.getElementById("video").play()");


But it is not Working , please clear me this out guys!







javascript java selenium selenium-webdriver






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 11:03









Andersson

34.3k103063




34.3k103063










asked Nov 8 at 10:49









koushick

1039




1039












  • driver.findElements(By.tagName("iframe")); then write your logic
    – bhupathi turaga
    Nov 8 at 10:53












  • driver.switchTo().frame(0); if u have two or more then 0,1,2...
    – bhupathi turaga
    Nov 8 at 10:54








  • 1




    driver.switchTo().frame(driver.findElement(By.ClassName("videoWrapper")));
    – bhupathi turaga
    Nov 8 at 10:59










  • videoWrapper is the style class of a div, not an iframe ID.
    – Selaron
    Nov 8 at 10:59


















  • driver.findElements(By.tagName("iframe")); then write your logic
    – bhupathi turaga
    Nov 8 at 10:53












  • driver.switchTo().frame(0); if u have two or more then 0,1,2...
    – bhupathi turaga
    Nov 8 at 10:54








  • 1




    driver.switchTo().frame(driver.findElement(By.ClassName("videoWrapper")));
    – bhupathi turaga
    Nov 8 at 10:59










  • videoWrapper is the style class of a div, not an iframe ID.
    – Selaron
    Nov 8 at 10:59
















driver.findElements(By.tagName("iframe")); then write your logic
– bhupathi turaga
Nov 8 at 10:53






driver.findElements(By.tagName("iframe")); then write your logic
– bhupathi turaga
Nov 8 at 10:53














driver.switchTo().frame(0); if u have two or more then 0,1,2...
– bhupathi turaga
Nov 8 at 10:54






driver.switchTo().frame(0); if u have two or more then 0,1,2...
– bhupathi turaga
Nov 8 at 10:54






1




1




driver.switchTo().frame(driver.findElement(By.ClassName("videoWrapper")));
– bhupathi turaga
Nov 8 at 10:59




driver.switchTo().frame(driver.findElement(By.ClassName("videoWrapper")));
– bhupathi turaga
Nov 8 at 10:59












videoWrapper is the style class of a div, not an iframe ID.
– Selaron
Nov 8 at 10:59




videoWrapper is the style class of a div, not an iframe ID.
– Selaron
Nov 8 at 10:59












2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










Try to use below code to switch to required frame:



driver.switchto().frame(driver.findElement(By.xpath("//div[@class='videoWrapper']/iframe")));


Also note that you cannot apply play() to div node, but to video node (e.g. <video></video>)






share|improve this answer





















  • Thanks man, now it switched to that frame, but without using play() how i can play the video?
    – koushick
    Nov 8 at 11:07










  • Depends on the element you need to handle. Is it video node? Share HTML for video-player also
    – Andersson
    Nov 8 at 11:08










  • Yes, it is youtube video which they uploaded in the site . For That they have used iframe.
    – koushick
    Nov 8 at 11:11










  • @koushick If it is a Youtube video, try driver.findElement(By.xpath("//button[@aria-label='Play']").click()
    – Andersson
    Nov 8 at 11:14












  • it is not working, but anyway thanks it switched to frame. Let Me Try with javascripexecutor and tell you!
    – koushick
    Nov 8 at 11:25


















up vote
-1
down vote













driver.switchTo().frame(driver.findElements(By.tagName("iframe"))); 





share|improve this answer



















  • 1




    iframe has no class name attribute
    – Andersson
    Nov 8 at 11:03






  • 3




    While this code snippet may solve the problem, it doesn't explain why or how it answers the question. Please include an explanation for your code, as that really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.
    – Luca Kiebel
    Nov 8 at 12:25











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206172%2fi-need-to-click-on-the-iframe-video%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










Try to use below code to switch to required frame:



driver.switchto().frame(driver.findElement(By.xpath("//div[@class='videoWrapper']/iframe")));


Also note that you cannot apply play() to div node, but to video node (e.g. <video></video>)






share|improve this answer





















  • Thanks man, now it switched to that frame, but without using play() how i can play the video?
    – koushick
    Nov 8 at 11:07










  • Depends on the element you need to handle. Is it video node? Share HTML for video-player also
    – Andersson
    Nov 8 at 11:08










  • Yes, it is youtube video which they uploaded in the site . For That they have used iframe.
    – koushick
    Nov 8 at 11:11










  • @koushick If it is a Youtube video, try driver.findElement(By.xpath("//button[@aria-label='Play']").click()
    – Andersson
    Nov 8 at 11:14












  • it is not working, but anyway thanks it switched to frame. Let Me Try with javascripexecutor and tell you!
    – koushick
    Nov 8 at 11:25















up vote
1
down vote



accepted










Try to use below code to switch to required frame:



driver.switchto().frame(driver.findElement(By.xpath("//div[@class='videoWrapper']/iframe")));


Also note that you cannot apply play() to div node, but to video node (e.g. <video></video>)






share|improve this answer





















  • Thanks man, now it switched to that frame, but without using play() how i can play the video?
    – koushick
    Nov 8 at 11:07










  • Depends on the element you need to handle. Is it video node? Share HTML for video-player also
    – Andersson
    Nov 8 at 11:08










  • Yes, it is youtube video which they uploaded in the site . For That they have used iframe.
    – koushick
    Nov 8 at 11:11










  • @koushick If it is a Youtube video, try driver.findElement(By.xpath("//button[@aria-label='Play']").click()
    – Andersson
    Nov 8 at 11:14












  • it is not working, but anyway thanks it switched to frame. Let Me Try with javascripexecutor and tell you!
    – koushick
    Nov 8 at 11:25













up vote
1
down vote



accepted







up vote
1
down vote



accepted






Try to use below code to switch to required frame:



driver.switchto().frame(driver.findElement(By.xpath("//div[@class='videoWrapper']/iframe")));


Also note that you cannot apply play() to div node, but to video node (e.g. <video></video>)






share|improve this answer












Try to use below code to switch to required frame:



driver.switchto().frame(driver.findElement(By.xpath("//div[@class='videoWrapper']/iframe")));


Also note that you cannot apply play() to div node, but to video node (e.g. <video></video>)







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 8 at 10:59









Andersson

34.3k103063




34.3k103063












  • Thanks man, now it switched to that frame, but without using play() how i can play the video?
    – koushick
    Nov 8 at 11:07










  • Depends on the element you need to handle. Is it video node? Share HTML for video-player also
    – Andersson
    Nov 8 at 11:08










  • Yes, it is youtube video which they uploaded in the site . For That they have used iframe.
    – koushick
    Nov 8 at 11:11










  • @koushick If it is a Youtube video, try driver.findElement(By.xpath("//button[@aria-label='Play']").click()
    – Andersson
    Nov 8 at 11:14












  • it is not working, but anyway thanks it switched to frame. Let Me Try with javascripexecutor and tell you!
    – koushick
    Nov 8 at 11:25


















  • Thanks man, now it switched to that frame, but without using play() how i can play the video?
    – koushick
    Nov 8 at 11:07










  • Depends on the element you need to handle. Is it video node? Share HTML for video-player also
    – Andersson
    Nov 8 at 11:08










  • Yes, it is youtube video which they uploaded in the site . For That they have used iframe.
    – koushick
    Nov 8 at 11:11










  • @koushick If it is a Youtube video, try driver.findElement(By.xpath("//button[@aria-label='Play']").click()
    – Andersson
    Nov 8 at 11:14












  • it is not working, but anyway thanks it switched to frame. Let Me Try with javascripexecutor and tell you!
    – koushick
    Nov 8 at 11:25
















Thanks man, now it switched to that frame, but without using play() how i can play the video?
– koushick
Nov 8 at 11:07




Thanks man, now it switched to that frame, but without using play() how i can play the video?
– koushick
Nov 8 at 11:07












Depends on the element you need to handle. Is it video node? Share HTML for video-player also
– Andersson
Nov 8 at 11:08




Depends on the element you need to handle. Is it video node? Share HTML for video-player also
– Andersson
Nov 8 at 11:08












Yes, it is youtube video which they uploaded in the site . For That they have used iframe.
– koushick
Nov 8 at 11:11




Yes, it is youtube video which they uploaded in the site . For That they have used iframe.
– koushick
Nov 8 at 11:11












@koushick If it is a Youtube video, try driver.findElement(By.xpath("//button[@aria-label='Play']").click()
– Andersson
Nov 8 at 11:14






@koushick If it is a Youtube video, try driver.findElement(By.xpath("//button[@aria-label='Play']").click()
– Andersson
Nov 8 at 11:14














it is not working, but anyway thanks it switched to frame. Let Me Try with javascripexecutor and tell you!
– koushick
Nov 8 at 11:25




it is not working, but anyway thanks it switched to frame. Let Me Try with javascripexecutor and tell you!
– koushick
Nov 8 at 11:25












up vote
-1
down vote













driver.switchTo().frame(driver.findElements(By.tagName("iframe"))); 





share|improve this answer



















  • 1




    iframe has no class name attribute
    – Andersson
    Nov 8 at 11:03






  • 3




    While this code snippet may solve the problem, it doesn't explain why or how it answers the question. Please include an explanation for your code, as that really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.
    – Luca Kiebel
    Nov 8 at 12:25















up vote
-1
down vote













driver.switchTo().frame(driver.findElements(By.tagName("iframe"))); 





share|improve this answer



















  • 1




    iframe has no class name attribute
    – Andersson
    Nov 8 at 11:03






  • 3




    While this code snippet may solve the problem, it doesn't explain why or how it answers the question. Please include an explanation for your code, as that really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.
    – Luca Kiebel
    Nov 8 at 12:25













up vote
-1
down vote










up vote
-1
down vote









driver.switchTo().frame(driver.findElements(By.tagName("iframe"))); 





share|improve this answer














driver.switchTo().frame(driver.findElements(By.tagName("iframe"))); 






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 8 at 11:05

























answered Nov 8 at 10:59









bhupathi turaga

14112




14112








  • 1




    iframe has no class name attribute
    – Andersson
    Nov 8 at 11:03






  • 3




    While this code snippet may solve the problem, it doesn't explain why or how it answers the question. Please include an explanation for your code, as that really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.
    – Luca Kiebel
    Nov 8 at 12:25














  • 1




    iframe has no class name attribute
    – Andersson
    Nov 8 at 11:03






  • 3




    While this code snippet may solve the problem, it doesn't explain why or how it answers the question. Please include an explanation for your code, as that really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.
    – Luca Kiebel
    Nov 8 at 12:25








1




1




iframe has no class name attribute
– Andersson
Nov 8 at 11:03




iframe has no class name attribute
– Andersson
Nov 8 at 11:03




3




3




While this code snippet may solve the problem, it doesn't explain why or how it answers the question. Please include an explanation for your code, as that really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.
– Luca Kiebel
Nov 8 at 12:25




While this code snippet may solve the problem, it doesn't explain why or how it answers the question. Please include an explanation for your code, as that really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.
– Luca Kiebel
Nov 8 at 12:25


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206172%2fi-need-to-click-on-the-iframe-video%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Schultheiß

Liste der Kulturdenkmale in Wilsdruff

Android Play Services Check