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!
javascript java selenium selenium-webdriver
add a comment |
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!
javascript java selenium selenium-webdriver
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
add a comment |
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!
javascript java selenium selenium-webdriver
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
javascript java selenium selenium-webdriver
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
add a comment |
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
add a comment |
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>
)
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 itvideo
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, trydriver.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
add a comment |
up vote
-1
down vote
driver.switchTo().frame(driver.findElements(By.tagName("iframe")));
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
add a comment |
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>
)
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 itvideo
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, trydriver.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
add a comment |
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>
)
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 itvideo
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, trydriver.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
add a comment |
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>
)
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>
)
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 itvideo
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, trydriver.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
add a comment |
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 itvideo
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, trydriver.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
add a comment |
up vote
-1
down vote
driver.switchTo().frame(driver.findElements(By.tagName("iframe")));
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
add a comment |
up vote
-1
down vote
driver.switchTo().frame(driver.findElements(By.tagName("iframe")));
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
add a comment |
up vote
-1
down vote
up vote
-1
down vote
driver.switchTo().frame(driver.findElements(By.tagName("iframe")));
driver.switchTo().frame(driver.findElements(By.tagName("iframe")));
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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