How to Select an dropdown element with Span tag in Selenium [duplicate]
This question already has an answer here:
Element should have been “select” but was “div” getting an error in selenium
2 answers
I'm trying to select an option from Dropdown with Span tag in Selenium. Below is my Selenium code
new Select (driver.findElement(By.cssSelector("span.select2-selection.select2-selection--single"))).selectByVisibleText("Prison");
Getting error 'org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "span"'
HTML Code for the dropdown is as below;
Kind request for any help.
html selenium
marked as duplicate by DebanjanB
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 2 at 13:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Element should have been “select” but was “div” getting an error in selenium
2 answers
I'm trying to select an option from Dropdown with Span tag in Selenium. Below is my Selenium code
new Select (driver.findElement(By.cssSelector("span.select2-selection.select2-selection--single"))).selectByVisibleText("Prison");
Getting error 'org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "span"'
HTML Code for the dropdown is as below;
Kind request for any help.
html selenium
marked as duplicate by DebanjanB
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 2 at 13:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Please don't post pictures of your code. Insert it in a codeblock.
– ochs.tobi
Jan 2 at 12:24
add a comment |
This question already has an answer here:
Element should have been “select” but was “div” getting an error in selenium
2 answers
I'm trying to select an option from Dropdown with Span tag in Selenium. Below is my Selenium code
new Select (driver.findElement(By.cssSelector("span.select2-selection.select2-selection--single"))).selectByVisibleText("Prison");
Getting error 'org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "span"'
HTML Code for the dropdown is as below;
Kind request for any help.
html selenium
This question already has an answer here:
Element should have been “select” but was “div” getting an error in selenium
2 answers
I'm trying to select an option from Dropdown with Span tag in Selenium. Below is my Selenium code
new Select (driver.findElement(By.cssSelector("span.select2-selection.select2-selection--single"))).selectByVisibleText("Prison");
Getting error 'org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "span"'
HTML Code for the dropdown is as below;
Kind request for any help.
This question already has an answer here:
Element should have been “select” but was “div” getting an error in selenium
2 answers
html selenium
html selenium
edited Jan 2 at 12:45


ochs.tobi
1,48471333
1,48471333
asked Jan 2 at 12:19
KaviKavi
11
11
marked as duplicate by DebanjanB
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 2 at 13:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by DebanjanB
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 2 at 13:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Please don't post pictures of your code. Insert it in a codeblock.
– ochs.tobi
Jan 2 at 12:24
add a comment |
1
Please don't post pictures of your code. Insert it in a codeblock.
– ochs.tobi
Jan 2 at 12:24
1
1
Please don't post pictures of your code. Insert it in a codeblock.
– ochs.tobi
Jan 2 at 12:24
Please don't post pictures of your code. Insert it in a codeblock.
– ochs.tobi
Jan 2 at 12:24
add a comment |
1 Answer
1
active
oldest
votes
you cannot use in select class. Try
Select sel = new Select(driver.findelement(By.id('P37_ACCOMMODATION_STATUS')));
sel.SelectByVisibleText('Prision');
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
you cannot use in select class. Try
Select sel = new Select(driver.findelement(By.id('P37_ACCOMMODATION_STATUS')));
sel.SelectByVisibleText('Prision');
add a comment |
you cannot use in select class. Try
Select sel = new Select(driver.findelement(By.id('P37_ACCOMMODATION_STATUS')));
sel.SelectByVisibleText('Prision');
add a comment |
you cannot use in select class. Try
Select sel = new Select(driver.findelement(By.id('P37_ACCOMMODATION_STATUS')));
sel.SelectByVisibleText('Prision');
you cannot use in select class. Try
Select sel = new Select(driver.findelement(By.id('P37_ACCOMMODATION_STATUS')));
sel.SelectByVisibleText('Prision');
edited Jan 2 at 13:28
answered Jan 2 at 13:20


NirmalKumarNirmalKumar
163
163
add a comment |
add a comment |
1
Please don't post pictures of your code. Insert it in a codeblock.
– ochs.tobi
Jan 2 at 12:24