How to Define main DIV if one of it childs consist of some text? Using c# & seleniumHow do I get a consistent byte representation of strings in C# without manually specifying an encoding?How to maximize the browser window in Selenium WebDriver (Selenium 2) using C#?How to select an option from drop down using Selenium WebDriver C#?How do I find an element that contains specific text in Selenium Webdriver (Python)?selenium InternetExporerDriver some elements click not consistently diringNullPointerException at initializing WebElements with @FindBy, using TestNG + Java + PageFactoryhow to get text present between html tags like <div>text</div> using selenium C#How to extract text from child Text Nodes - SeleniumCount some nodes by Selenium, using xpath. C#
Citing CPLEX 12.9
If I travelled back in time to invest in X company to make a fortune, roughly what is the probability that it would fail?
Job interview by video at home and privacy concerns
How do French and other Romance language speakers cope with the movable do system?
Why is there such a singular place for bird watching?
Realistically, how much do you need to start investing?
Generating numbers with cubes
How dangerous are my worn rims?
Why is music is taught by reading sheet music?
Duck, duck, gone!
Digital Bananas
How to say "respectively" in German when listing (enumerating) things
Everyone Gets a Window Seat
IEEE 754 square root with Newton-Raphson
What did the Federation give the Prophets in exchange for access to the wormhole in DS9?
Is it appropriate to "shop" through high-impact journals before sending the paper to more specialized journals?
Giving a good fancy look to a simple table
Rank-one positive decomposition for a entry-wise positive positive definite matrix
Is "weekend warrior" derogatory?
Lighthouse Alternatives
Did Joe Biden "stop a prosecution" into his son in Ukraine? And did he brag about stopping the prosecution?
Filter by pills/buttons instead of using a select - angular
Knights and Knaves: What does C say?
Can Fabled Passage generate two mana with Amulet of Vigor?
How to Define main DIV if one of it childs consist of some text? Using c# & selenium
How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How to maximize the browser window in Selenium WebDriver (Selenium 2) using C#?How to select an option from drop down using Selenium WebDriver C#?How do I find an element that contains specific text in Selenium Webdriver (Python)?selenium InternetExporerDriver some elements click not consistently diringNullPointerException at initializing WebElements with @FindBy, using TestNG + Java + PageFactoryhow to get text present between html tags like <div>text</div> using selenium C#How to extract text from child Text Nodes - SeleniumCount some nodes by Selenium, using xpath. C#
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
The main DIV consist of text in one of it's childs & consist of button i need to click if text is present. How can i define the main div to continue work with this if one of it's childs strictly consist of text i need?
Structure seems like:
<Div class="Green"> (Main Div i mentioned in description)
<Div class="Yel">
<Div class="Ora">
<Div class="Pur">
<span>text must be present</span>
I need to define main div , to proceed with this by findelement. then.
c# selenium-webdriver
add a comment
|
The main DIV consist of text in one of it's childs & consist of button i need to click if text is present. How can i define the main div to continue work with this if one of it's childs strictly consist of text i need?
Structure seems like:
<Div class="Green"> (Main Div i mentioned in description)
<Div class="Yel">
<Div class="Ora">
<Div class="Pur">
<span>text must be present</span>
I need to define main div , to proceed with this by findelement. then.
c# selenium-webdriver
why you don't close div element <div> </div> ??
– Muath
Mar 28 at 21:23
add a comment
|
The main DIV consist of text in one of it's childs & consist of button i need to click if text is present. How can i define the main div to continue work with this if one of it's childs strictly consist of text i need?
Structure seems like:
<Div class="Green"> (Main Div i mentioned in description)
<Div class="Yel">
<Div class="Ora">
<Div class="Pur">
<span>text must be present</span>
I need to define main div , to proceed with this by findelement. then.
c# selenium-webdriver
The main DIV consist of text in one of it's childs & consist of button i need to click if text is present. How can i define the main div to continue work with this if one of it's childs strictly consist of text i need?
Structure seems like:
<Div class="Green"> (Main Div i mentioned in description)
<Div class="Yel">
<Div class="Ora">
<Div class="Pur">
<span>text must be present</span>
I need to define main div , to proceed with this by findelement. then.
c# selenium-webdriver
c# selenium-webdriver
asked Mar 28 at 21:17
GeorgeGeorge
13 bronze badges
13 bronze badges
why you don't close div element <div> </div> ??
– Muath
Mar 28 at 21:23
add a comment
|
why you don't close div element <div> </div> ??
– Muath
Mar 28 at 21:23
why you don't close div element <div> </div> ??
– Muath
Mar 28 at 21:23
why you don't close div element <div> </div> ??
– Muath
Mar 28 at 21:23
add a comment
|
1 Answer
1
active
oldest
votes
Have you tried the below.
Browser.FindElement(By.XPath("//div[@class='Green' and //span[normalize-space(.)='137']]//button[@class='needed_item']")).Click()
or
Browser.FindElement(By.XPath("//span[normalize-space(.)='137']/ancestor::div[@class='Green']//button[@class='needed_item']")).Click()
This xpath will first find the main div which have a span with 137
text. And then click on the button which have the class needed_item
. Considered the below structure for the xpath.
<div @understand='main_div' @class='Green'>
<div @understand='child_div1'></div>
<div @understand='child_div2'>
<span @understand='target_span'> 137 </span>
</div>
<div @understand='child_div3></div>
<div @understand='div with button'>
<button @class='needed_item'>Target Button</button>
</div>
</div>
Let me know if there is any change in the structure.
add a comment
|
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',
autoActivateHeartbeat: false,
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/4.0/"u003ecc by-sa 4.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
);
);
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%2f55406980%2fhow-to-define-main-div-if-one-of-it-childs-consist-of-some-text-using-c-sharp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Have you tried the below.
Browser.FindElement(By.XPath("//div[@class='Green' and //span[normalize-space(.)='137']]//button[@class='needed_item']")).Click()
or
Browser.FindElement(By.XPath("//span[normalize-space(.)='137']/ancestor::div[@class='Green']//button[@class='needed_item']")).Click()
This xpath will first find the main div which have a span with 137
text. And then click on the button which have the class needed_item
. Considered the below structure for the xpath.
<div @understand='main_div' @class='Green'>
<div @understand='child_div1'></div>
<div @understand='child_div2'>
<span @understand='target_span'> 137 </span>
</div>
<div @understand='child_div3></div>
<div @understand='div with button'>
<button @class='needed_item'>Target Button</button>
</div>
</div>
Let me know if there is any change in the structure.
add a comment
|
Have you tried the below.
Browser.FindElement(By.XPath("//div[@class='Green' and //span[normalize-space(.)='137']]//button[@class='needed_item']")).Click()
or
Browser.FindElement(By.XPath("//span[normalize-space(.)='137']/ancestor::div[@class='Green']//button[@class='needed_item']")).Click()
This xpath will first find the main div which have a span with 137
text. And then click on the button which have the class needed_item
. Considered the below structure for the xpath.
<div @understand='main_div' @class='Green'>
<div @understand='child_div1'></div>
<div @understand='child_div2'>
<span @understand='target_span'> 137 </span>
</div>
<div @understand='child_div3></div>
<div @understand='div with button'>
<button @class='needed_item'>Target Button</button>
</div>
</div>
Let me know if there is any change in the structure.
add a comment
|
Have you tried the below.
Browser.FindElement(By.XPath("//div[@class='Green' and //span[normalize-space(.)='137']]//button[@class='needed_item']")).Click()
or
Browser.FindElement(By.XPath("//span[normalize-space(.)='137']/ancestor::div[@class='Green']//button[@class='needed_item']")).Click()
This xpath will first find the main div which have a span with 137
text. And then click on the button which have the class needed_item
. Considered the below structure for the xpath.
<div @understand='main_div' @class='Green'>
<div @understand='child_div1'></div>
<div @understand='child_div2'>
<span @understand='target_span'> 137 </span>
</div>
<div @understand='child_div3></div>
<div @understand='div with button'>
<button @class='needed_item'>Target Button</button>
</div>
</div>
Let me know if there is any change in the structure.
Have you tried the below.
Browser.FindElement(By.XPath("//div[@class='Green' and //span[normalize-space(.)='137']]//button[@class='needed_item']")).Click()
or
Browser.FindElement(By.XPath("//span[normalize-space(.)='137']/ancestor::div[@class='Green']//button[@class='needed_item']")).Click()
This xpath will first find the main div which have a span with 137
text. And then click on the button which have the class needed_item
. Considered the below structure for the xpath.
<div @understand='main_div' @class='Green'>
<div @understand='child_div1'></div>
<div @understand='child_div2'>
<span @understand='target_span'> 137 </span>
</div>
<div @understand='child_div3></div>
<div @understand='div with button'>
<button @class='needed_item'>Target Button</button>
</div>
</div>
Let me know if there is any change in the structure.
edited Mar 30 at 5:08
answered Mar 30 at 5:02
supputurisupputuri
7,0692 gold badges8 silver badges26 bronze badges
7,0692 gold badges8 silver badges26 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f55406980%2fhow-to-define-main-div-if-one-of-it-childs-consist-of-some-text-using-c-sharp%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
why you don't close div element <div> </div> ??
– Muath
Mar 28 at 21:23