开发者

Selenium Compare storedVars to Text

I'm trying to compare a stored variable (user inputs variable value) to a predefined text. This is for testing on a beta site compared to the production site. An example of the code is as follows:

<tr>
    <td>store</td>
    <td>Production</td>
    <td>ProductionOrBeta</td>
</tr>
<tr>
    <td>stor开发者_高级运维eEval</td>
    <td>((storedVars['ProductionOrBeta'] = &quot;Beta&quot;)?'http://betasite.com/':'http://productionsite.com/')</td>
    <td>targetWebsite</td>
</tr>
<tr>
    <td>open</td>
    <td>${targetWebsite}</td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>((${ProductionOrBeta}=&quot;Beta&quot;)?'betalogin':'productionlogin')</td>
    <td>loginName</td>
</tr>
<tr>
    <td>storeEval</td>
    <td>((${ProductionOrBeta}=&quot;Beta&quot;)?'betapw':'productionpw')</td>
    <td>loginPassword</td>
</tr>

I've tried this with single and double quote, both produce the same results. The above code seems logical to me but it doesn't seem possible. No matter what the variable "ProductionOrBeta" holds the betasite is always open.

Thank you,

Jesse Smothermon


I got it. Here's the code

<tr>
    <td>store</td>
    <td>Production</td>
    <td>ProductionOrBeta</td>
</tr>
<tr>
    <td>storeEval</td>
    <td>((storedVars['ProductionOrBeta'] == &quot;Beta&quot;)?'http://betasite.com/':'http://productionsite.com/')</td>
    <td>targetWebsite</td>
</tr>
<tr>
    <td>open</td>
    <td>${targetWebsite}</td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>((storedVars['ProductionOrBeta']==&quot;Beta&quot;)?'betalogin':'productionlogin')</td>
    <td>loginName</td>
</tr>
<tr>
    <td>storeEval</td>
    <td>((storedVars['ProductionOrBeta']==&quot;Beta&quot;)?'betapw':'productionpw')</td>
    <td>loginPassword</td>
</tr>

The difference being the "storedVars['ProductionOrBeta']" all the way through and the double equals ("==") as opposed to the single equals ("=").

Thank you,

Jesse Smothermon

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜